【发布时间】:2011-04-14 13:21:05
【问题描述】:
我是 Objective-C 的新手,我尝试编写一个 iPad 应用程序(Objective-C 2.0,Xcode 4.0.1)。 我“玩”了 ActionSheet 以了解它是如何工作的。在一个 nib 文件中,我放置了一个绑定到我的“buttonPressed”方法的按钮。
我已经写了这段代码:
-(IBAction)buttonPressed
{
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"My Action Sheet" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"OK" otherButtonTitles:@"Test", nil];
NSLog([NSString stringWithFormat:@"%d", [myActionSheet numberOfButtons]]);
NSLog([myActionSheet buttonTitleAtIndex:0]);
NSLog([myActionSheet buttonTitleAtIndex:1]);
NSLog([myActionSheet buttonTitleAtIndex:2]);
[myActionSheet showInView:self.view];
[myActionSheet release];
}
这是 NSLog 结果:
2011-04-14 14:52:30.428 TrampManage[3568:207] 3
2011-04-14 14:52:30.429 TrampManage[3568:207] OK
2011-04-14 14:52:30.430 TrampManage[3568:207] Test
2011-04-14 14:52:30.432 TrampManage[3568:207] Cancel
但显示的视图却完全不同(参见图片:http://www.imagup.com/data/1117452257.html)。目前,我有一个简单的问题:为什么我的“取消”按钮没有出现?
【问题讨论】:
标签: objective-c ipad xcode4