小编Pen*_*One的帖子

使用多种颜色iOS填写UIView

我想用多种颜色填写UIView背景.我想将它用作各种状态栏,因此如果完成1/2必要步骤,则UIView背景将为1/2绿色和1/2红色.当用户完成更多步骤(比如2/3)时,更多的UIView背景变为绿色(在这种情况下为2/3).

我猜我需要覆盖

-(void) drawREct: (CGRect) rect
Run Code Online (Sandbox Code Playgroud)

我想我会得到UIView,弄清楚它有多大,然后把它分成2个矩形然后填充那些矩形.

另一种选择是以编程方式添加2个UIViews,但我是IB的粉丝.

有可能像我想要的那样划分UIView吗?

谢谢

uiview drawrect ios cgrect

3
推荐指数
1
解决办法
7101
查看次数

iPhone UITableView创建部分

我试图在我的UITableView中创建更多的部分,我似乎无法搞清楚.我希望将"查看完整网站"和"视频"链接移动到他们自己的部分,并将这些单元格的高度更改为75.我可以创建一个新单元格,但我无法弄清楚如何正确定位它.

    typedef enum { SectionHeader, SectionDetail } Sections;
    typedef enum { SectionHeaderTitle, SectionHeaderDate, SectionHeaderURL,            SectionHeaderEnclosure } HeaderRows;
    typedef enum { SectionDetailSummary } DetailRows;

    @implementation MediaDetailTableViewController

    @synthesize item, dateString, summaryString, teachings;

    #pragma mark -
    #pragma mark Initialization

    - (id)initWithStyle:(UITableViewStyle)style {
    if ((self = [super initWithStyle:style])) {

    }
    return self;
    }

    #pragma mark -
    #pragma mark View lifecycle

    - (void)viewDidLoad {

    // Super
    [super viewDidLoad];

    // Date
    if (item.date) {
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateStyle:NSDateFormatterMediumStyle];
        [formatter setTimeStyle:NSDateFormatterMediumStyle];
        self.dateString = …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c uitableview

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

UIButton没有改变标题

我在Interface Builder中有一个UIButton,其初始标题为"Use Current Location".上面有一个UITextField,用户可以在其中键入地址或邮政编码.按钮和文本字段都是IBOutlets.

存在这些项的视图的视图控制器是a UITextFieldDelegate.在委托方法中,(BOOL)textFieldShouldReturn:(UITextField *)textField我想根据文本字段中是否包含任何内容来更改按钮标题.我的方法看起来像这样:

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSLog([textField text]);

    if([[textField text] length] == 0)
    {
        NSLog(@"AAAAAAAAA");
        [go setTitle:@"Use Current Location" forState:UIControlStateNormal];
    }
    else
    {
        NSLog(@"BBBBBBB");
        [go setTitle:@"Use This Address" forState:UIControlStateNormal];
    }
    [textField resignFirstResponder];
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

注意:goUIButton.

此方法未按预期执行,但每次都记录正确的语句.按钮的标题不会改变.

任何帮助将特别感谢.

iphone cocoa-touch objective-c uibutton ios

3
推荐指数
1
解决办法
1238
查看次数

iPhone Dev - 如何使UITableView具有适合其中所有单元格的精确高度

我有以下内容:

http://i.imgur.com/0nDcS.png

我想这样做,以便tableview停在"So"单元格,而不是在它下面的所有空白单元格(大计划是有一堆多项选择问题,如该图片中的那个,全部在在一个scrollview上彼此顶部).我猜我需要设置tableView的框架,但我想知道是否有一种简单的方法可以在运行时计算实现单元格的tableview部分的精确高度(图片中带有文本的部分).这很棘手,因为我做了它,以便每个单元格的高度可以改变以适应其中的文本量.有人有什么建议吗?

iphone objective-c uitableview

3
推荐指数
1
解决办法
1276
查看次数

UINavigationController - 应用程序试图在目标上推送一个nil视图控制器,我缺少什么?

我有问题让我的导航控制器正常运行!如果我在RootViewController中单击表格的单元格,它似乎不是下一个ViewController.

错误消息读取

"应用程序试图将nil视图控制器推向目标."

所以我分配了一些错误的东西,我的猜测,我可能遗漏了我所遵循的书中的重要内容.

所以问题出现在我的RootViewController.m中:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    UINavigationController *navigationController= [[UINavigationController alloc]init];

    switch ([indexPath row]) {

        case 0:
            [navigationController pushViewController:kundeViewCon animated:YES];
            break;

        case 1:
            [navigationController pushViewController:kalenderViewCon animated:YES];
            break;

        case 2:
            [navigationController pushViewController:wunschViewCon animated:YES];
            break;
    } 
}
Run Code Online (Sandbox Code Playgroud)

在我的AppDelegate.m中,我正在做以下事情来将RootViewController设置为NavigationController:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

// Navigation Controller

    RootViewController *rootViewController = [[RootViewController alloc]init];

    navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController];

    self.window.backgroundColor = [UIColor whiteColor];

    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible]; …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller didselectrowatindexpath ios

3
推荐指数
1
解决办法
9769
查看次数

检测UIImageView上的触碰事件

我在UIView上放置了4个UIImageView,并将它命名为

UIImageView myImg1 = [[UIImageView alloc] init];     
UIImageView myImg2 = [[UIImageView alloc] init];     
UIImageView myImg3 = [[UIImageView alloc] init]; 
UIImageView myImg4 = [[UIImageView alloc] init];
Run Code Online (Sandbox Code Playgroud)

我怎么能告诉编译器我刚刚触及UIImageView 1或UIImaveView 2.如果我只能使用UIImageView来完成这个任务,而不是按钮.请指导我这个问题.谢谢

iphone

3
推荐指数
1
解决办法
3492
查看次数

UIAlertView可以通过委托传递字符串和int

我有一个UIAlertView(实际上有几个),-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex如果用户没有按下取消,我正在使用该方法触发一个动作.这是我的代码:

- (void)doStuff {   
        // complicated time consuming code here to produce:
        NSString *mySecretString = [self complicatedRoutine];
        int myInt = [self otherComplicatedRoutine];

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"HERE'S THE STUFF" 
                                                        message:myPublicString // derived from mySecretString
                                                       delegate:nil 
                                              cancelButtonTitle:@"Cancel" 
                                              otherButtonTitles:@"Go On", nil];
        [alert setTag:3];
        [alert show];
        [alert release];        
    }
Run Code Online (Sandbox Code Playgroud)

然后我想做的是以下内容:

- (void)alertView:(UIAlertView *)alertView 
clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        if ([alertView tag] == 3) {
                        NSLog(@"%d: %@",myInt,mySecretString);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,这种方法不知道mySecretStringmyInt.我绝对不想重新计算它们,我不想将它们存储为属性,因为-(void)doStuff很少(如果有的话)调用它们.有没有一种方法来此额外的信息添加到UIAlertView中,以避免重新计算或存储 …

iphone uialertview ios

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

通用iPad/iPhone XIBs - Xcode 4

我想制作一个具有两个不同XIB文件的通用应用程序.一个用于iPhone,一个用于iPad.他们使用相同的代码,只是不同的UI.我如何创建一个"通用"应用程序?

谢谢.

iphone xib universal ipad xcode4

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

如何禁用UITableView的单个单元格的选择?

一旦用户点击触发操作的单元格,我想禁用用户交互,然后在操作完成后重新启用用户交互.谁能告诉我怎么做?

iphone uitableview

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

如何复制此用户界面设计?

我想在Mint.com应用程序中创建一个类似于on的UI.它是带有UITableView单元格的UIScrollView吗?

注意每个块/单元格中有多个数据值.

在此输入图像描述

iphone user-interface xcode objective-c ios

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