小编Dan*_*any的帖子

iOS教程中的Xml解析

嗨我正在创建一个应用程序,必须从服务器中的xml文件打印标签中的值.我尝试阅读谷歌搜索下的一些文档..但我找不到它...有没有人知道简单的教程或用于在我的应用程序中集成xml解析的任何示例代码.

iphone xcode nsurlconnection nsxmlparser ios

15
推荐指数
2
解决办法
7万
查看次数

如何通过编程方式为UIButtons组设置单个背景图像

这是我以编程方式创建按钮的代码:

NSArray *buttonImage=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
                      [UIImage imageNamed:@"Cover_1.png"],
                      [UIImage imageNamed:@"Cover_2.png"],
                      [UIImage imageNamed:@"Cover_3.png"],
                      [UIImage imageNamed:@"Cover_4.png"],
                      [UIImage imageNamed:@"Cover_5.png"],
                      [UIImage imageNamed:@"Cover_6.png"],
                      [UIImage imageNamed:@"Cover_7.png"],nil];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 200.0f, 200.0f);
[button setTitle:[NSString stringWithFormat:@"%i", index] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
button.titleLabel.font = [button.titleLabel.font fontWithSize:50];

[button setImage:buttonImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
return button;
Run Code Online (Sandbox Code Playgroud)

但是在运行它时我无法进入模拟器并且它会抛出一个Signal Sigabart错误.有人可以帮忙吗?

iphone uibutton ios programmatically-created

7
推荐指数
1
解决办法
1293
查看次数

如何在ios4中以编程方式将图像数组添加到UIImage视图?

我需要在单个视图中显示图像数组,这些图像在icarousel(时间机器,封面流等等)中具有各种效果.我将使用单一样式,其中所有图像都必须显示..这是我的代码.M文件..

UIImage *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
NSLog(@"hi");

img.image=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
                      [UIImage imageNamed:@"Cover_1.png"],
                      [UIImage imageNamed:@"Cover_2.png"],
                      [UIImage imageNamed:@"Cover_3.png"],
                      [UIImage imageNamed:@"Cover_4.png"],
                      [UIImage imageNamed:@"Cover_5.png"],
                      [UIImage imageNamed:@"Cover_6.png"],
                      [UIImage imageNamed:@"Cover_7.png"],nil];
Run Code Online (Sandbox Code Playgroud)

但它没有用......任何人都可以帮忙...

iphone xcode uiimage ios icarousel

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

如何从UITextfield获取价值并将其发送到电子邮件?

我创建了一个包含表单的应用程序,必须填写适当的文本字段..现在我需要在textfield中获取所有数据并将其发送到email.here我的代码用于撰写电子邮件

- (IBAction)compose:(id)sender 
{
if (text1.text=@"" && text2.text=@"" && text3.text=@"" && text4.text=@"" && text5.text=@"") {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                                                    message:@"Please enter all the field details" 
                                                   delegate:nil 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles: nil];
}
                                                                             else{


if ([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

    mailer.mailComposeDelegate = self;

    [mailer setSubject:[NSString stringWithFormat:@"Appointment From Mr/Mrs. %@",text1.text]];

    NSArray *toRecipients = [NSArray arrayWithObjects:@"xxx@xxxx.com", nil];
    [mailer setToRecipients:toRecipients];



    NSString *emailBody =[NSString stringWithFormat:@"Name =%@\nDate= %@\nPreferred Time Slot= %@\nE-Mail=%@\nSpecific Requests=",text1.text,text2.text,text3.text,text4.text,text5.text]; 
    [mailer setMessageBody:emailBody isHTML:NO];


    [self presentModalViewController:mailer animated:YES];

    [mailer release];
}
else …
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitextfield ios

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

UITableViewCell删除每行之间的白色并显示UIView的背景图像

这是我的应用程序的图像

我的应用图片

如您所见,每行都有白线.我该怎么走出那条线.

这是我完成的单元格代码

cell.backgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"conta.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];   
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.textLabel.text = [tableArray objectAtIndex:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
tableView.backgroundColor=[UIColor clearColor];
return cell;
Run Code Online (Sandbox Code Playgroud)

我需要消灭每行中的白线.我怎样才能做到这一点?

iphone xcode uitableview ios

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

从NSDictionary打印带有JSON对象的标签文本

我的json文件看起来像这样

[{"id":"1","category":"New Category1","title":"New Product2","description":"Please type a description1","imgurl":"http:\/\/s.wordpress.org\/about\/images\/wordpress-logo-notext-bg.png","spectitle":"Specification","specvalue":"Value"},{"id":"2","category":"Mobile","title":"Samsung","description":"Please type a description","imgurl":"http:\/\/s.wordpress.org\/about\/images\/wordpress-logo-notext-bg.png","spectitle":"Price","specvalue":"100$"}]
Run Code Online (Sandbox Code Playgroud)

我有4个标签,必须在单个标签中打印id,类别,标题,描述.我已成功解析整个json对象并打印在一个标签中.我需要显示所有json对象和相应的类别到相应的标签.

NSString *labelstring =[NSString stringWithFormat:@"%@",[json objectAtIndex:0]];
label1.text=[NSString stringwithformat: objectForKey:@"id"]; 
 label2.text=[NSString stringwithformat:objectForKey:@"category"];
 label3.text=[NSString stringwithformat:objectForKey:@"title"];  
 label4.text=[NSString stringwithformat:objectForKey:@"description"]; 
Run Code Online (Sandbox Code Playgroud)

这里json是NSArray的一个变量,有URL信息和那些东西......但如果我试图获得个人价值,我无法得到它..指导请...

xcode json objective-c uilabel ios

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

接收内存警告的未知原因

让我快来发.到目前为止我的代码没有问题.我唯一关心的是内存管理.让我的应用程序逻辑清晰.

  1. 当App全局启动时,声明了NSmutableDictionary,并且使用pathForResource:ofType方法添加了近300个图像,其中包含各种键和图像.

  2. 在我的rootViewController加载后,我的35个自定义UIViews被添加到另一个键的同一个全局字典中.(这个rootViewController不会经常使用)

  3. 我有4个ViewControllers,我将把这个UIViews和图像用于全局字典中的所有ViewControllers.

  4. 我移动到另一个viewController时释放视图并使其为nil.

  5. 我的问题是当我在ViewControllers之间快速移动时(1 - > 2 - > 3 - > 4 - > 1).如果我这样做4-6次就会崩溃.

  6. 如果我慢慢移动,它会在10到15次之后崩溃.

我不知道为什么它崩溃甚至我的Live字节最大5 MB.所有我从控制台和设备日志获得的是Received Memory警告.使用仪器时没有泄漏,没有脏的尺寸或居民大小.

虽然在模拟器中运行我不会在多个设备上遇到此问题但我遇到了这个问题.

我有疑虑

  • 是否善于在全球词典中添加一切.我的想法是减少每个ViewControllers的加载时间

  • 为了重用相同的图像,我们可以使用pathForResource或图像命名方法.

提前致谢 ...

xcode instruments uiimage nsmutabledictionary ios

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