首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

多个参数传递请问

2012-04-20 
多个参数传递请教有一方法如下:+(void)initWithArguments:(NSString*)title withMessage:(NSString*)messa

多个参数传递请教
有一方法如下:
  +(void)initWithArguments:(NSString*)title withMessage:(NSString*)message delegate:(id)sender buttonName:(NSString*)btnName buttonNames:(NSString*)other, ...{

UIAlertView *alter=[[UIAlertView alloc] initWithTitle:title 
message:message 
delegate:sender 
cancelButtonTitle:btnName 
otherButtonTitles:(这里的参数该写么写?),nil];
[alter show];
[alter release];
}
==========
希望达人解答???对于达人来说应该很简单吧

[解决办法]
我知道了。是C中的不定参数吧。
我知道可以这样用:
va_list va_Average;
NSString *str;
va_start(va_Average,other);//va_start 第二个参数为... 的前一个参数
while (other) {
str = va_arg(params, NSString *);
//do something...//可以将title们放到一个array里去。
else break;
}
va_end(va_Average);

然后,用UIAlertView的 - (NSInteger)addButtonWithTitle:(NSString *)title 这个方法,依次加上去好了。

热点排行