在我的申请中,我需要分别得到小时和分钟:
NSString *currentHour=[string1 substringWithRange: NSMakeRange(0,2)];
int currentHourInNumber=[currentHour intValue];
Run Code Online (Sandbox Code Playgroud)
考虑string1包含11:59:13 AM来自datepicker的包含.
在这里,如果我使用上面的代码,如果它大于9 NSMakeRange(0,1),可以获得小时.否则我需要改变以获得1到9之间的小时.
是否有任何方法可以获得小时,分钟等?
在此先感谢,请提供示例代码.
嗨,我需要在导航栏中以编程方式设置右侧的按钮,这样如果我按下按钮,我将执行一些操作.我以编程方式创建了导航栏;
navBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0,0,320,44) ];
Run Code Online (Sandbox Code Playgroud)
同样,我需要在此导航栏的右侧添加按钮.为此我用过,
1.
UIView* container = [[UIView alloc] init];
// create a button and add it to the container
UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 130, 44.01)];
[container addSubview:button];
[button release];
// add another button
button = [[UIButton alloc] initWithFrame:CGRectMake(160, 0, 50, 44.01)];
[container addSubview:button];
[button release];
// now create a Bar button item
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:container];
// set the nav bar's right button item
self.navigationItem.rightBarButtonItem = item;
[item release];
Run Code Online (Sandbox Code Playgroud)
2. …
我以编程方式将UIButton和UITextView作为子视图添加到我的视图中.
notesDescriptionView = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,460)];
notesDescriptionView.backgroundColor = [UIColor redColor];
[self.view addSubview:notesDescriptionView];
textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,320,420)];
[self.view addSubview:textView];
printf("\n description button \n");
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button
addTarget:self action:@selector(cancel:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 420.0, 160.0, 40.0);
[self.view addSubview:button];
Run Code Online (Sandbox Code Playgroud)
我需要在单击按钮时删除所有子视图.
我试过了:
[self.view removeFromSuperView]
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
在我的应用程序中,我需要根据设备iPad/iPhone 4/iPhone 3设备获得正确的图像.
例如:
我有一个名为a.png(宽度40,高度20)的iPhone 3/iPod图像和a@2x.png(宽度80,高度40)iPhone 4.
如果我提到了代码
UIImage *myImage=[UIImage imageNamed:@"a.png"];
Run Code Online (Sandbox Code Playgroud)
如果它是iPhone 4,myImage包含(80*40)图像.如果它是iPod/iPhone 3,myImage包含(40*20)图像.
我的问题是我如何获得iPad(60*30)的图像,如上面的命名约定.
我试着给出a~ipad.png一个图像名称,它不起作用.你能指出哪里有错误吗?
如果我使用[UIDevice currentDevice];isIpod - > load(60*30)图像使用条件,否则为iPhone/iPod加载图像它工作正常.
但我需要在不使用条件的情况下使用它,并使用像a.pngiPhone/iPod,a.@2x.pngiPhone 4和iPad 等命名约定.
提前致谢.
我在一个标签中有2:01:20 PM格式; 经过一些计算后,我需要更改该标签的小时和/或分钟.
也就是说,是否可以通过将其转换为NSDate对象并像下午3:20:30那样修改小时和分钟来更改该标签值?
这有什么setter方法吗?
嗨,我是iphone开发的新手,任何人都可以解释为什么使用setDelegate,我们应该在哪里使用它.
[request setDelegate:sender];
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我有项目,这包含头文件.
#import "Three20/TTButton.h"
#import "Three20/TTStyle.h"
#import "Three20/TTStyleSheet.h"
#import "Three20/TTView.h"
#import "Three20/TTShape.h"
Run Code Online (Sandbox Code Playgroud)
但我没有得到这样的文件,目录错误.但我可以看到那些TTButton.h,TTStyle.h ...都在Three20文件夹中.
请帮助我,提前谢谢.