Skip to content

Instantly share code, notes, and snippets.

@S1U
Created November 23, 2014 08:12
Show Gist options
  • Save S1U/475262e6de902fd9bca8 to your computer and use it in GitHub Desktop.
Save S1U/475262e6de902fd9bca8 to your computer and use it in GitHub Desktop.
background color disappeared
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@end
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor grayColor];
UILabel * testLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 300)];
testLabel.center = self.view.center;
testLabel.text = @"Second";
testLabel.textAlignment = NSTextAlignmentCenter;
testLabel.backgroundColor = [UIColor orangeColor];
[self.view addSubview:testLabel];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate>
@end
#import "ViewController.h"
#import "SecondViewController.h"
#import "AMWaveTransition.h"
@interface ViewController ()
@property (copy, nonatomic) NSArray * data;
@property (strong, nonatomic) UITableView * tableView;
@end
@implementation ViewController
@synthesize data, tableView;
- (void)viewDidLoad {
[super viewDidLoad];
data = @[@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",];
tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
[self.view addSubview:tableView];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [data count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * cellIdentifier = @"CellIdentifier";
UITableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.textLabel.text = data[indexPath.row];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SecondViewController * secondVC = [[SecondViewController alloc] init];
[self.navigationController pushViewController:secondVC animated:YES];
}
#pragma mark - AMWaveTransition Methods
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController*)fromVC
toViewController:(UIViewController*)toVC
{
if (operation != UINavigationControllerOperationNone) {
// Return your preferred transition operation
return [AMWaveTransition transitionWithOperation:operation];
}
return nil;
}
- (NSArray*)visibleCells
{
return [self.tableView visibleCells];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.navigationController setDelegate:self];
}
- (void)dealloc
{
[self.navigationController setDelegate:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment