UIActionSheet标题的奇怪问题

时间:2014-02-21 05:33:09

标签: ios objective-c ios7 uiactionsheet

我遇到了一个奇怪的问题,我似乎无法更改UIActionSheet的标题。这是我初始化操作表的方式:

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Options" delegate:self cancelButtonTitle:@"Nevermind" destructiveButtonTitle:destructiveTitle otherButtonTitles:nil];
popupQuery.actionSheetStyle = UIActionSheetStyleDefault;
[popupQuery showInView:self];

除主要操作表标题外,所有内容(包括按钮标题)都可以正常工作。出于某种原因,它在运行时总是显示“标题”,而不是“选项”。更奇怪的是,这个相同的代码以前工作得很好,最近才破解,可能是更新了SDK或iOS。

请注意,我还可以使用以下代码更改标题:

[[[popupQuery subviews] objectAtIndex:0] setText:@"Options"];

如果我添加上面一行,它会显示正确的标题;但是,我担心使用这样的黑客而不是标准的解决方案。关于可能发生什么的任何想法?

更新

以下代码:

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Options" delegate:self cancelButtonTitle:@"Nevermind" destructiveButtonTitle:destructiveTitle otherButtonTitles:nil];

NSLog(@"title is : %@", popupQuery.title);
[popupQuery setTitle:@"Options"];
NSLog(@"title is now : %@", popupQuery.title);

产生输出:

2014-02-20 21:48:29.862 APP[68219:907] title is : title
2014-02-20 21:48:29.862 APP[68219:907] title is now : title
而不是我期望的,即“选项”两次。

0 个答案:

没有答案