iphone - AlertView 的 init 方法中的参数

标签 iphone objective-c ios ios4 iphone-sdk-3.0

我想知道是否有一种方法可以在 UIAlertView 的构造函数中传递与 initWithTitle 中不同的参数。我特别想传递一个 NSArray。是否可以? 这是代码:

@implementation UIAlertTableView


- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {


    array=[NSArray arrayWithObjects:@"Capitaliz. semplice",@"Capitaliz. composta",@"Pagamenti rateali",@"Bond", nil];

    table = [[UITableView alloc] initWithFrame:CGRectZero  style:UITableViewStylePlain];

    table.delegate=self;
    table.dataSource=self;


    [self addSubview:table];
}
return self;
}

谢谢

最佳答案

每当您问自己这样的问题时,请搜索“[UIClassName] 类引用”

UIAlertView类引用:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html

它的 init 需要一个 NSString,而不是一个字符串数组:

- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate     cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...

关于iphone - AlertView 的 init 方法中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7937044/

相关文章:

iphone - 如何正确使用 Apple 的 Reachability 类来判断互联网是否正常?

iphone - UISearchBar + didSelectRowAtIndexPath + cellForRowAtIndexPath

android - 通过设备或服务器向 Urbanairship 注册 APID

ios - 使用静态单元格创 build 置场景 - 附上屏幕截图和简单测试用例

ios - 过渡不适用于 SwiftUI 中的路由器

iphone - MKAnnotationViews 的 Z 排序

c++ - 列出 Xcode、iOS 中最后的 X malloc/free 调用

ios - ALAsset defaultRepresentation fullResolutionImage

ios - 带有 NSDictionary、NSArray、JSON 和 HTML 数据的 NSPredicate

ios - 如果没有收到数据则抛出异常