打个草稿,今儿太晚了 周末有时间继续补充吧
问题:
1.unrecognized selector sent to instance
方法名错误
2.UIApplicationMain 的地方:关于EXC_BAD_ACCESS
product-,Edit Scheme,在Environment Varibles中 添加 NSZombieEnabled YES 最后结果
关于出现僵尸信号SIGBAT或者EXC_BAD_ACCESS的解决方案
http://www.cnblogs.com/zlja/archive/2012/04/12/2444793.html用这个方法能定位到底是哪一个对象的内存问题
3.performSelector:withObject:withObject:]: message sent to deallocated
4.使用storyboard
Xcode4.2没有windows模板了,不过这个例子用带storyboard的single View App模板也能实现,
更多storyboard的功能还得去摸索
5.viewController不加载 init,改用viewDidLoad
查到没有init方法,用其他几个方法之一可以简单代替,多个viewController的初始还得继续学习
http://blog.youkuaiyun.com/zltianhen/article/details/6596973
6.两个按钮公用一个方法的实现
还有一种依靠sender去检查不同按钮的办法:
@implementation ViewController
@synthesize statusText;
-(IBAction)buttonPressed:(id)sender
{
NSString *title = [sender titleForState:UIControlStateNormal];//sender用于区分是哪个button,也就获得了不同的button的文字 titleForState是根据button状态获取文字的函数,比C#复杂的设计
NSString *newText = [[NSStringalloc] initWithFormat:@"%@ button pressed.", title];
statusText.text = newText;
}
@end
最后上个截图: