美好的一天,我有这个应用程序将近3个月,我付了开发人员来制作这个应用程序。
http://www.youtube.com/watch?v=sFju-GsN_-s
由于开发人员不再回复我的邮件,因为他收到了付款。 (大声笑) 我想为这个应用添加更多页面,这就是我问这个问题的原因。 iOS Swiping functions。 但不幸的是我无法让它发挥作用。这是.m文件的完整代码:
//
// 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
这是页面排列,PAGE1&lt; - PAGE2 - &gt; PAGE3,页面2是打开应用程序时显示的默认页面,因此,如果向右滑动则显示第3页,如果您向左滑动2次,它显示第一页,我也希望页面滑动更逼真,我想当我刷它的时候跟着手指像iphone的希望页面一样,当你滑动应用程序图标时。
这是应用获取其所有数据的电子表格, https://docs.google.com/a/ttttt.us/spreadsheet/ccc?key=0AkgWFqjLQz0TdDlJMk9JOU9lY2RJWUxONUlodWY3b0E#gid=0 选项卡是基于我想要制作的应用程序页面排列的,所以基本上这将是新的应用程序页面
Page5<--Page2<--Page2-->Page3-->Page4
。
我希望你能帮助我:(非常感谢你!