小编Dan*_*i A的帖子

在一个视图中创建两个操作表

我在一个视图中创建了两个操作表.有两个按钮,每个按钮将启动一个操作表.

问题:当我在两个操作表中按下第一个选项时,会触发相同的操作.

这是我的代码:

-(IBAction) ChangeArrow:(id)sender{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Change Arrow"
                                                         delegate:self
                                                cancelButtonTitle:@"cancel"
                                           destructiveButtonTitle:@"Red"
                                                otherButtonTitles:@"Blue",@"Black",nil];
[actionSheet showInView:self.view];
[actionSheet release];}
- (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex ==[actionSheet destructiveButtonIndex]) {
    self.bar.image=[UIImage imageNamed:@"red"];

}
else if(buttonIndex == 1){
    self.bar.image=[UIImage imageNamed:@"blue"];

}
else if(buttonIndex == 2){
    self.bar.image=[UIImage imageNamed:@"dark"];}
}
Run Code Online (Sandbox Code Playgroud)

//第二个行动表:

-(IBAction) Background:(id)sender{
UIActionSheet *actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Change Background"
                                                         delegate:self
                                                cancelButtonTitle:@"cancel"
                                           destructiveButtonTitle:@"Sky"
                                                otherButtonTitles:@"Thumbs",@"Smiley",nil];
[actionSheet2 showInView:self.view];
[actionSheet2 release];
} 
- (void) actionSheet2: (UIActionSheet *)actionSheet2 didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex ==[actionSheet2 destructiveButtonIndex]) {
    self.background.image=[UIImage …
Run Code Online (Sandbox Code Playgroud)

iphone uiactionsheet

5
推荐指数
1
解决办法
5001
查看次数

是否可以在 MarkDown 中创建切换(开关)?

我想为用 MarkDown 编写的文档实现类似的效果:在此输入图像描述

切换按钮将在 Objective-C 或 Swift 中显示此示例代码。我在 MD 的文档中找不到任何表明这是可能的内容。有什么建议么?

markdown github-flavored-markdown

5
推荐指数
2
解决办法
1万
查看次数

Objective-C计算字符串值

这是我的主要内容:

int x=0;
NSString *new=[[NSString alloc]initWithString:@"9+4"];
x=[new intValue];
NSLog(@"hi %i",x);
Run Code Online (Sandbox Code Playgroud)

这导致9 ...因为赋予字符串的intValue将只读取数字并在字符不是数字时停止.

那么如何打印我的字符串的结果并得到一个13而不是?

int objective-c nslog nsstring

2
推荐指数
1
解决办法
1747
查看次数

UITableView detailTextLabel - iphone开发

为什么"detailTextLabel"不再起作用了?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell.
    cell.textLabel.text=[listData objectAtIndex:[indexPath row]];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;


    cell.detailTextLabel.text=@"hi";
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

iphone uitableview

0
推荐指数
1
解决办法
1756
查看次数