小编Vik*_*ica的帖子

从NSUserDefaults存储和检索长数组

如何将长阵列存储NSUserDefaults并检索?

以下是我的长阵列的外观:

long *arr;
arr = new long [10];
for(int i = 0 ; i<10 ; i++)
{
arr[i] = i;
}
Run Code Online (Sandbox Code Playgroud)

现在我想将其存储arrNSUserDefaults稍后然后检索它

cocoa-touch objective-c ios

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

在iOS中单击UIButton时传递字符串值

我在ios上点击了uibutton,检查了很多文章.但通常,人们使用标签属性作为替代.

但我找到了以下解决方案:

 UIButton *btnComLike=[[UIButton alloc] init];

 [btnComLike setFrame:CGRectMake(127, 20, 30, 15)];
 [btnComLike addTarget:self action:@selector(btnCommentLike_click:) forControlEvents:UIControlEventTouchUpInside];
 [btnComLike setTitle:@"Like" forState:UIControlStateNormal];
 [btnComLike setTitle:@"my any string value" forState:UIControlStateReserved];
Run Code Online (Sandbox Code Playgroud)

和处理方:

-(void)btnCommentLike_click:(id)sender
{
 NSLog(@"%@",[sender titleForState:UIControlStateReserved]);

}
Run Code Online (Sandbox Code Playgroud)

这是一个可行的解决方案吗?我认为一方面就是利用这种状态UIControlStateReserved.

或者使用这种技术有任何缺点吗?

如果有,请告诉我有什么问题?

cocoa-touch objective-c uibutton ios

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

NSXMLParser不解析某些内容

我的iOS应用程序解析从远程服务器获取的xml(我不能以任何方式影响).当它遇到如下所示的xml标记时:

<tag a="x" b="y" c="z">
  this is a
  <aabb/>
  content
  <ccdd/>
  string
</tag>
Run Code Online (Sandbox Code Playgroud)

它只解析内容的第一部分("这是一个"),而忽略了这些单个标记之后的所有内容.无论这些单个标签中有多少个跟随,如果它只有一个标签,它也会跳过其余标签.我没有真正得到这种行为,是否有解释或方法来克服这个问题?

cocoa-touch objective-c nsxmlparser

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

如何在tableview单元格中传递字典?

import UIKit

class ViewController: UIViewController, UITableViewDataSource,UITableViewDelegate {

    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var tableView1: UITableView!

    let element = ["Sports": #imageLiteral(resourceName: "ios"),"Grocery":#imageLiteral(resourceName: "ios"),"Cosmetics":#imageLiteral(resourceName: "ios")]

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView1.delegate = self
        tableView1.dataSource = self
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { …
Run Code Online (Sandbox Code Playgroud)

dictionary uitableview swift

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

如何将文件保存到appbundle中

我有一个名为的图像my-image.我可以将此图像保存到应用程序包吗?如果是,您可以向我提供代码或路径吗?

截至目前,我有以下代码 -

NSData * imageData = UIImagePNGRepresentation(userSavedImage); //convert image into .png format.
NSFileManager * fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString * documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
NSString * fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",txtImageName.text]]; //add our image to the path

[fileManager createFileAtPath:fullPath contents:imageData …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c app-bundle

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

如何在iOS中动态生成对象?

我想动态生成按钮.下面的代码生成2个按钮.但是我怎样才能编写一个循环来生成批量(100或1000)按钮.

- (void)viewDidLoad
{
//allocate the view
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

//set the view's background color
self.view.backgroundColor = [UIColor whiteColor];

//create the buttons
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];

//set the position of the button
button.frame = CGRectMake(100, 170, 100, 30);
button1.frame = CGRectMake(200, 170, 100, 30);

//set the button's title
[button setTitle:@"Click Me!" forState:UIControlStateNormal];
[button1 setTitle:@"Click!" forState:UIControlStateNormal];

//listen for clicks
[button addTarget:self action:@selector(buttonPressed)
 forControlEvents:UIControlEventTouchUpInside];
[button1 addTarget:self action:@selector(buttonPressed)
 forControlEvents:UIControlEventTouchUpInside];

//add the button to …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios

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

iOS 4.3在滚动视图上不显示标签

标签位于屏幕中央(或下方),iphone 4.3不显示.但iphone与iOS 5.0显示.全部由IB制造.

UPD :(代码)

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.view.backgroundColor = [UIColor blackColor];
        [scroll setContentSize:CGSizeMake(320, 700)];
        scroll.frame = CGRectMake(0, 0, 320, 460);
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uiscrollview uilabel ios4

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

如何在iOS中解析这种类型的JSON响应?

我是iOS新手。我想在iOS中解析这种类型的JSON响应。这是贝宝的回应。我想访问所有数据并制作字典并将其存储以用于其他目的。如何访问所有字段并将其设置为字典?

{

    client =     {

        environment = sandbox;

        "paypal_sdk_version" = "2.0.1";

        platform = iOS;

        "product_name" = "PayPal iOS SDK";

    };

    response =     {

        "create_time" = "2014-04-12T05:15:25Z";

        id = "PAY-72670124ZX823130UKNEMX3I";

        intent = sale;

        state = approved;

    };

    "response_type" = payment;

}
Run Code Online (Sandbox Code Playgroud)

json objective-c ios

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

密码验证的正则表达式Objective-C

任何人都可以帮助我,我需要一个正则表达式密码验证.

条件:密码最多为8个字符数字或字母,至少有一个特殊字符

提前致谢.

regex cocoa-touch objective-c ios

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