이 내 데이터 파싱 코드 파싱이 완료되었습니다. 코어 데이터에 해당 데이터를 추가하는 방법
-(void) DataRetireve {deatilinfoarray = [[NSMutableArray 할당] init]; NSURL * url = [NSURL URLWithString : @ " http://sms.instatalkcommunications.com/apireq/GetSMSCategories?t=1&h=admin¶m=1 "]; ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL : url]; [요청 setDelegate : self]; [startAsynchronous 요청]; }
(void) requestFinished : (ASIHTTPRequest *) request {
NSError * error = [요청 오류]; NSString * responseString = nil;
if (! error) {responseString = [request responseString];
SBJsonParser *parser = [[SBJsonParser alloc] init] ;
NSMutableArray *jsondata = [parser objectWithString:responseString];
NSMutableArray *jsondata1 = [[NSMutableArray alloc]init];
for(int i=0;i<jsondata.count;i++)
{
info *myinfo=[[info alloc]init];
myinfo.Id=@"Id";
myinfo.Name=@"Name";
myinfo.IsActive=@"IsActive";
[jsondata1 addObject:myinfo];
NSLog(@"%@",responseString);
}
for(int i=0;i<jsondata1.count;i++)
{
info *myinfo= [jsondata1 objectAtIndex:i];
[jsondata1 addObject:myinfo];
}
사용할 수있는 가장 간단한 방법은 다음과 같습니다.
int yPossion = 50, xPossion = 10; int temp = 0;
UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame];
[self.view addSubview:scrollView];
for (int i = 0; i<50; i++){
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setBackgroundColor:[UIColor blackColor]];
[aButton setBackgroundImage:[UIImage imageNamed:@"icon-menu.png"] forState:UIControlStateNormal];
[aButton setTitle:[NSString stringWithFormat:@" %d",i] forState:UIControlStateNormal];
[aButton setFrame:CGRectMake(xPossion, yPossion, 100, 50)];
[scrollView addSubview:aButton];
xPossion += aButton.frame.size.width+15;
temp++;
if (temp==3) {
yPossion = aButton.frame.origin.y+aButton.frame.size.height+15;
temp = 0;
xPossion = 10;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, yPossion+50)];
}
}
그러나 autoLayout 제약 조건을 사용하려면이 링크를 따라 가면 도움이 될 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다