数控滚齿机编程系统真的这么难做吗

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
可以看出,main函数的作用在于调用UIApplicationMain方法来创建一个UIApplication对象实例,同时也管理了此类的实例的内存释放。那么获取UIApplication对象实例,代码如下:假设UIApplicationDelegate协议继承类XXXXAppDelegateUIApplication *app = [UIApplication sharedApplication];XXXXAppDelegate *d = (XXXXAppDelegate *)app.//Test these code ,在main函数中创建了UIApplication实例,同时也就绑定了XXXXAppDelegate看看原型&&& int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName );&&& This function is called in the main entry point to create the application object and the application delegate and set up the event cycle.&&& argc: The count
this usually is the corresponding parameter to main.&&& argv: A variab this usually is the corresponding parameter to main.&&& principalClassName: The name of the UIApplicationclass or subclass.&&& delegateClassName: The name of the class from which the application delegate is instantiated.UIApplication部分:UIApplicationMain-&&&& UIApplication&&& UIApplicationDelegate实现类UIApplication-&&&& sharedApplication类方法获取当前程序的UIApplication实例&&& delegate属性获取UIApplicationDelegate实现类的实例&&& windows属性获取当前程序涉及到窗口类数组&&& keyWindow属性获取当前程序关键窗口即然有了UIApplicationDelegate协议的实现类,那如何实现UIViewController/subclass的初始化?实现Controller类的初始化的地方有两处:application:didFinishLaunchingWithOptions:applicationDidFinishLaunching:这两个方法,后者是前期版本下的。在iOS3.0以及之后,应该使用前者来完成开始这个过程。XCode4运行的是application:didFinishLaunchingWithOptions:当然,你也可以删除application:didFinishLaunchingWithOptions:,自己添加applicationDidFinishLaunching方法来实现。不推荐此操作。看下实际对UIApplicationDelegate如何编写其实现类#import &UIKit/UIKit.h&@class NavSmallPhoneViewC@interface NavSmallPhoneAppDelegate : NSObject &UIApplicationDelegate& {}@property (nonatomic, retain) IBOutlet UIWindow *@property (nonatomic, retain) IBOutlet NavSmallPhoneViewController *viewC@end#import "NavSmallPhoneAppDelegate.h"#import "NavSmallPhoneViewController.h"@implementation NavSmallPhoneAppDelegate@synthesize window=_@synthesize viewController=_viewC@synthesize- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// Override point for customization after application launch.
self.window.rootViewController = self.viewC
[self.window makeKeyAndVisible];
//Todo 这部分代码是未测试和说明一个问题的:当前UIApplicationDelegate实现类中的window属性来源哪?
UIWindow *w = [UIApplication sharedApplication].keyW
NSLog(@"%@\n%@" ,w ,self.window);
if (w == self.window)
NSLog(@"AppDelegate 'window is UIApplication current keyWindow!");
return YES;}/*为了方便阅读,这里仅保留了需要看的方法。其他自动生成的代码在此移除,看完整的,自己通过XCode4自动生成*/- (void)dealloc{
[_window release];
[_viewController release];
[super dealloc];}@end看头文件,你发现实现类,有了两个属性,window和viewController;就是保存当前实现类所关联的window和视图控制器通过运行,输出“AppDelegate 'window is UIApplication current keyWindow!”,说明实现类的window属性来源UIApplication实例当前的keyWindow属性。也就是说,如果UIApplication实例只有一份UIWindow实例,那肯定和其UIApplicationDelegate实现类的window属性指向同一UIWindow实例。之所以在UIApplicationDelegate实现类定义这么两个属性,就是为了更方便的使用UIWindow和UIViewController,作用就是建立对象树状关系,便于彼此调用和实现。在这里,应该清楚了UIApplication和UIViewController之间是通过UIWinodw来关联的,尽管在UIApplicationDelegate实现类中定义一个viewController属性。修改下上面的关系图:常规iPhone程序对象结构如下:对象个数&&& &&& 对象类型1&&& &&& UIApplication1&&& &&& &&& UIApplicationDelegate/subclass1&&& &&& &&& &&& &&& &&&&UIWindow1&&& &&& &&& &&& &&& &&& & .rootViewController属性1,N&&& &&& &&& &&& &&& &&& &&& &&& &&& UIViewController/subclass1,N&&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& UIView/subclsss根据现在的对象结构图,可以知道UIWindow实例在此仅仅是起承上启下的作用。UIWindow继承UIView:UIResponder:NSObject现在可以看下UIViewController继承UIResponder:NSObjectUIViewController其子类UINavigationController和UITabBarController为复杂视图控制器和视图的层次结构提供额外的行为处理功能。针对问题看下,有哪些视图控制器可访问?& parentViewController& property& searchDisplayController& property& splitViewController& property& modalViewController& property& navigationController& property& tabBarController& property&&& 上述控制器访问器都是只读,说明这些控制器是由内部或初始化就进行处理。& 从这里来看,至少可以说明一点,Controller之间的关联是存在的~~&&最关键,怎么去管理视图?属性view和方法loadViewUIView又如何得到它的操作者?又如何管理自身的子视图?继承于UIResponder:NSObject如果UIView包含在UIViewController下,只能顺起获取到对应的UIView,暂时未知如何根据UIView获取UIViewControllerUIView关于管理视图层次,如下:Managing the View Hierarchy&&&&&&superview& property&&&&&&subviews& property&&&&&&window& property&&& – addSubview:&&& – bringSubviewToFront:&&& – sendSubviewToBack:&&& – removeFromSuperview&&& – insertSubview:atIndex:&&& – insertSubview:aboveSubview:&&& – insertSubview:belowSubview:&&& – exchangeSubviewAtIndex:withSubviewAtIndex:&&& – isDescendantOfView:&&&&感觉可以通过属性window来获取Controller,从某一个角度来说,这个Controller应该是当前视图的父对象=======================================================================================================UIView.window属性来源于当前UIApplication.keyWindow可以通过此属性让UIView间接获取到该视图的UIViewController类文中涉及红色粗体,是本文的相关答案标记。
阅读(7091)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'UIApplication详解',
blogAbstract:'常规iPhone程序对象结构如下:对象个数&&& &&& 对象类型1&&& &&& UIApplication1&&& &&& &&& UIApplicationDelegate/subclass1,N&&& &&& &&& &&&',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:7,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'-1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}iphone - Referencing AppDelegate instance variables - Stack Overflow
Join the Stack Overflow Community
Stack Overflow is a community of 7.0 million programmers, just like you, helping each other.
J it only takes a minute:
I have a project that is based on the Navigation Based Application template.
In the AppDelegate are the methods -applicationDidFinishLoading: and -applicationWillTerminate:.
In those methods, I am loading and saving the application data, and storing it in an instance variable (it is actually an object-graph).
When the application loads, it loads MainWindow.xib, which has a NavigationConroller, which in turn has a RootViewController.
The RootViewController nibName property points to RootView (my actual controller class).
In my class, I wish to refer to the object that I created in the -applicationDidFinishLoading: method, so that I can get a reference to it.
Can anyone tell me how to do that?
I know how to reference between objects that I have created programmatically, but I can't seem to figure out to thread my way back, given that the middle step was done from within the NIB file.
44.9k66599
For variables (usually the model data structure) which I need to access it anywhere in the app, declare them in your AppDelegate class. When you need to reference it:
YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
//and then access the variable by appDelegate.variable
3,14521516
If I understand your question, you want to reference member variables/properties in your AppDelegate object? The simplest way is to use [[UIApplication sharedApplication] delegate] to return a reference to your object.
If you've got a property called window, you could do this:
*mainWindow = [[[UIApplication sharedApplication] delegate] window];
//do something with mainWindow
1,78111437
75.1k20163166
Here's a well defined portable alternative for iOS4.0 and up:
UIApplication *myApplication = [UIApplication sharedApplication];
UIWindow *mainWindow = [myApplication keyWindow];
UIViewController *rootViewController = [mainWindow rootViewController];
or, in one line,
UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
Don't forget to set the window's rootViewController property (say in IB) or this will do jack.
16.7k2694135
I define a macro and use it like this :-
#define appDelegateShared ((AppDelegate *)[UIApplication sharedApplication].delegate)
In My Code:-
appDelegateShared.myVariable=anotherV
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
rev .25660
Stack Overflow works best with JavaScript enabled问题:如何在Appdelegate中通过获取keyWindow来present一个UIViewAlertViewController
描述:1.问题描述我想要在- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions中弹出present出一个UIViewAlertViewController,效果就是在启动页的时候弹出更新提示,但是因为当前的这个window还没有成为keyWindow,所以在启动页消失后,层次图就会变成下面这样。是否只能等首页出现弹出UIAlertViewController才能正确的在keyWindow上弹出?2.代码[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertControler animated:YES completion:^{
也使用过UIWindow *window = [UIApplication sharedApplication].delegate.
[window makeKeyAndVisible];
[window.rootViewController presentViewController:alertControler animated:YES completion:^{
3.请教1.怎么样才是正确的姿势。。。2.是否是因为当前的keyWindow和启动图过后出现首页时的keyWindow不同。(我觉得是这个原因)解决方案1:为什么一定要用keywindow呢?用导航控制器或者tabBarController不可以么?解决方案2:用导航推不行吗?解决方案3:为何不测试一下呢,打印下它们的地址,看看是不是同一个?解决方案4:根据你的需求,你应该在启动页里操作,而不是入口类
以上介绍了“如何在Appdelegate中通过获取keyWindow来present一个UIViewAlertViewController”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:/itwd/1146046.html
上一篇: 下一篇:[iOS]APP代码实践:建立一个辅助的APP类,减少对AppDelegate的修改
最开始接触iOS开发的时候,如果需要一些全局变量或者全局函数的时候,总是直接在AppDelegate中添加,因为AppDelegate可以直接获取
[UIApplication sharedApplication].delegate
但是时间长了还是觉得这样不太好,AppDelegate本身有其自己的作用(对于App本身的一些事件进行处理,如启动,切换,推送),这样做感觉怪怪的,所以还是自己弄一个专门处理我们所需的全局变亮或者全局函数的对象会更好一些
//APPHelper.h
@interface APPHelper
+ (APPHelper*)
- (void) configureWindow:(UIWindow*)
@property (nonatomic, readonly) AppDelegate *
@property (strong, readonly) UIWindow *
//APPHelper.m
@interface APPHelper ()
@implementation APPHelper
- (id)init
self = [super init];
if (self) {
_delegate = (GGAppDelegate*)[UIApplication sharedApplication].
+ (APPHelper *)call
static dispatch_once_t
static APPHelper *appI
dispatch_once(&onceQueue, ^{
appInstance = [[APPHelper alloc] init];
return appI
- (UIWindow *)window
return self.delegate.
- (void)configureWindow:(UIWindow*)window
UINavigationController *nav = [[UINavigationController alloc] init];
window.rootViewController =
然后 在预编译头*.pch中加入
#import &AppHelper.h&
#define APP ([APPHelper call])
就可以直接在代码的任意一个地方直接使用此类了,如
//设置APP为圆角
APP.window.layer.cornerRadius = 5.0f;
APP.window.layer.masksToBounds = YES;

我要回帖

更多关于 国产数控滚齿机 的文章

 

随机推荐