Ios Xcode在单个视图应用程序上添加更多页面
好朋友,我有这个应用程序将近3个月了,我付钱给一个开发者来制作这个应用程序 因为开发者不再回复我的消息,因为他得到了付款。(笑) 我想向这个应用程序添加更多页面,这就是我问这个问题的原因。 但不幸的是我不能让它工作。这是.m文件的全部代码:Ios Xcode在单个视图应用程序上添加更多页面,ios,objective-c,xcode,Ios,Objective C,Xcode,好朋友,我有这个应用程序将近3个月了,我付钱给一个开发者来制作这个应用程序 因为开发者不再回复我的消息,因为他得到了付款。(笑) 我想向这个应用程序添加更多页面,这就是我问这个问题的原因。 但不幸的是我不能让它工作。这是.m文件的全部代码: // // MainViewController.m // SpreadSheet // // Created by Cai on 8/21/13. // Copyright (c) 2013 quianse. All rights reserve
//
// MainViewController.m
// SpreadSheet
//
// Created by Cai on 8/21/13.
// Copyright (c) 2013 quianse. All rights reserved.
//
#import "MainViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface MainViewController ()
@end
@implementation MainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.ar = [[NSMutableArray alloc] init];
NSArray *Months = [[NSArray alloc] initWithObjects: @"JAN",@"FEB",@"MAT",@"APR",@"MAY",@"JUN",@"JUL",@"AUG",@"SEP",@"OCT",@"NOV",@"DEC", nil];
NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
[DateFormatter setDateFormat:@"M"];
self.currentMonth = [Months objectAtIndex:[[DateFormatter stringFromDate:[NSDate date]] integerValue]-1];
NSLog(@"%@",self.currentMonth);
self.imageStatus = 1;
}
- (void)viewWillAppear:(BOOL)animated
{
delegate = (SpreadSheetAppDelegate*)[[UIApplication sharedApplication] delegate];
[delegate.self.navcon setNavigationBarHidden:true];
NSString *theURL = [NSString stringWithFormat:@"https://docs.google.com/spreadsheet/pub?key=0AkgWFqjLQz0TdDlJMk9JOU9lY2RJWUxONUlodWY3b0E&single=true&gid=%d&output=csv",self.imageStatus];
NSString *theFile = [NSString stringWithContentsOfURL:[NSURL URLWithString:theURL] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@",theFile);
NSArray *theCells = [theFile componentsSeparatedByString:@"\n"];
for (int i=1; i < [theCells count]; i++)
{
if (i > 0)
{
NSArray *value =[[theCells objectAtIndex:i] componentsSeparatedByString:@","];
[self.ar addObject:value];
NSLog(@"%@:%@",[value objectAtIndex:0],[value objectAtIndex:1]);
}
}
[NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(updateCounter:) userInfo:nil repeats:YES];
}
-(void) updateCounter:(NSTimer *)theTimer
{
NSString *theURL = [NSString stringWithFormat:@"https://docs.google.com/spreadsheet/pub?key=0AkgWFqjLQz0TdDlJMk9JOU9lY2RJWUxONUlodWY3b0E&single=true&gid=%d&output=csv",self.imageStatus];
NSString *theFile = [NSString stringWithContentsOfURL:[NSURL URLWithString:theURL] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@",theFile);
NSArray *theCells = [theFile componentsSeparatedByString:@"\n"];
[self.ar removeAllObjects];
for (int i=0; i < [theCells count]; i++)
{
if (i > 0)
{
NSArray *value =[[theCells objectAtIndex:i] componentsSeparatedByString:@","];
[self.ar addObject:value];
NSLog(@"%@:%@",[value objectAtIndex:0],[value objectAtIndex:1]);
}
}
[self.myTable reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.ar count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
// making the cell as the type of CustomCell
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil)
{
//making the object from CustomCell.xib
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = (CustomCell *)[nib objectAtIndex:0];
}
else
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell_iPad" owner:self options:nil];
cell = (CustomCell *)[nib objectAtIndex:0];
}
}
[cell setBackgroundColor:[UIColor clearColor]];
if (indexPath.row == 0)
{
self.lblCurrent.text = [[self.ar objectAtIndex:indexPath.row] objectAtIndex:2];
}
cell.URN.text = [[self.ar objectAtIndex:indexPath.row] objectAtIndex:0];
if (indexPath.row == 0)
{
self.lblTitle.text = [[self.ar objectAtIndex:indexPath.row] objectAtIndex:3];
}
cell.URN.text = [[self.ar objectAtIndex:indexPath.row] objectAtIndex:0];
cell.WorkStatus.text = [[self.ar objectAtIndex:indexPath.row] objectAtIndex:1] ;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
return 30;
}
else
{
return 70;
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
self.startPosition = [touch locationInView:self.view];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint endPosition = [touch locationInView:self.view];
if (self.imageStatus>0)
{
if (self.startPosition.x < endPosition.x)
{
// Right swipe
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromLeft;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:myViewController.view];
self.imageStatus --;
if (self.imageStatus == 0)
{
self.myImage.image = [UIImage imageNamed:@"blue_back.png"];
}
else
{
self.myImage.image = [UIImage imageNamed:@"black_back.png"];
}
}
}
if (self.imageStatus<2)
{
if (self.startPosition.x > endPosition.x)
{
// Left swipe
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromRight;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:myViewController.view];
self.imageStatus ++;
if (self.imageStatus == 2)
{
self.myImage.image = [UIImage imageNamed:@"red_back.png"];
}
else
{
self.myImage.image = [UIImage imageNamed:@"black_back.png"];
}
}
}
[self updateCounter:0];
NSLog(@"%d",[self imageStatus]);
[[self myTable] reloadData];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[_lblCurrent release];
[_myTable release];
[_myImage release];
[super dealloc];
}
@end
//
//MainViewController.m
//电子表格
//
//由Cai于2013年8月21日创建。
//版权所有(c)2013 quianse。版权所有。
//
#导入“MainViewController.h”
#进口
@接口MainViewController()
@结束
@实现主视图控制器
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad
{
[超级视图下载];
//从nib加载视图后,执行任何其他设置。
self.ar=[[NSMutableArray alloc]init];
NSArray*月=[[NSArray alloc]initWithObjects:“一月”、“二月”、“四月”、“五月”、“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”、“十二月”、“无”);
NSDateFormatter*DateFormatter=[[NSDateFormatter alloc]init];
[日期格式化程序setDateFormat:@“M”];
self.currentMonth=[Months objectAtIndex:[[DateFormatter stringFromDate:[NSDate date]]integerValue]-1];
NSLog(@“%@”,自当前月);
self.imageStatus=1;
}
-(无效)视图将显示:(BOOL)动画
{
delegate=(电子表格应用程序委派*)[[UIApplication sharedApplication]委派];
[delegate.self.navcon setNavigationBarHidden:true];
NSString*URL=[NSString stringWithFormat:@]https://docs.google.com/spreadsheet/pub?key=0AkgWFqjLQz0TdDlJMk9JOU9lY2RJWUxONUlodWY3b0E&single=true&gid=%d&output=csv“,self.imageStatus];
NSString*theFile=[NSString stringWithContentsOfURL:[NSURL URLWithString:theURL]编码:NSUTF8STRING编码错误:nil];
NSLog(@“%@”,文件);
NSArray*theCells=[由字符串分隔的文件组件:@“\n”];
对于(int i=1;i<[细胞计数];i++)
{
如果(i>0)
{
NSArray*值=[[Cells ObjectatinIndex:i]由字符串@“,”分隔的组件;
[self.ar addObject:value];
NSLog(@“%@:%@”,[value objectAtIndex:0],[value objectAtIndex:1]);
}
}
[NSTimer scheduledTimerWithTimeInterval:60目标:自选择器:@selector(updateCounter:)用户信息:无重复:是];
}
-(void)updateCounter:(NSTimer*)计时器
{
NSString*URL=[NSString stringWithFormat:@]https://docs.google.com/spreadsheet/pub?key=0AkgWFqjLQz0TdDlJMk9JOU9lY2RJWUxONUlodWY3b0E&single=true&gid=%d&output=csv“,self.imageStatus];
NSString*theFile=[NSString stringWithContentsOfURL:[NSURL URLWithString:theURL]编码:NSUTF8STRING编码错误:nil];
NSLog(@“%@”,文件);
NSArray*theCells=[由字符串分隔的文件组件:@“\n”];
[self.ar removeAllObjects];
对于(int i=0;i<[细胞计数];i++)
{
如果(i>0)
{
NSArray*值=[[Cells ObjectatinIndex:i]由字符串@“,”分隔的组件;
[self.ar addObject:value];
NSLog(@“%@:%@”,[value objectAtIndex:0],[value objectAtIndex:1]);
}
}
[self.myTable重载数据];
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
返回[self.ar count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
//使单元格成为CustomCell的类型
CustomCell*单元格=(CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil)
{
//从CustomCell.xib生成对象
if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone)
{
NSArray*nib=[[NSBundle mainBundle]loadNibNamed:@“CustomCell”所有者:自选项:nil];
单元格=(CustomCell*)[nib对象索引:0];
}
其他的
{
NSArray*nib=[[NSBundle mainBundle]loadNibNamed:@“CustomCell_iPad”所有者:自选项:nil];
单元格=(CustomCell*)[nib对象索引:0];
}
}
[cell setBackgroundColor:[UIColor clearColor]];
if(indexPath.row==0)
{
self.lblCurrent.text=[[self.ar objectAtIndex:indexPath.row]objectAtIndex:2];
}
cell.URN.text=[[self.ar objectAtIndex:indexath.row]objectAtIndex:0];
if(indexPath.row==0)
{
self.lblTitle.text=[[self.ar objectAtIndex:indexath.row]objectAtIndex:3];
}
cell.URN.text=[[self.ar objectAtIndex:indexath.row]objectAtIndex:0];
cell.WorkStatus.text=[[self.ar objectAtIndex:indexath.row]objectAtIndex:1];
返回单元;
}
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath
{
[tableView取消行索引路径:索引路径:否];
}
-(CGFloat)tableView:(UITableView*)表视图行高度索引路径:(NSIndexPath*)索引路径
{
if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone)
{
返回30;
}
其他的
{
返回70;
}
}
-(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件{
UITouch*touch=[触摸任何对象];
self.startPosition=[触摸位置视图:self.view];
}
-(void)touchesend:(NSSet*)toucheevent:(UIEvent*)event{
UITouch*touch=[触摸任何对象];
CGPoint endPosition=[触摸位置视图:self.view];
如果(self.imageStatus>0)
{
if(self.startPosition.x