Open judaco opened 7 years ago
//
// ViewController.m
// UIScrollView
//
// Created by hackeru on 10/05/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
{
UIImage * img1;
UIImageView * imageView;
UIScrollView * scrollView;
}
- (void)viewDidLoad {
[super viewDidLoad];
img1 = [UIImage imageNamed:@"img1"];
imageView = [[UIImageView alloc] initWithImage:img1];
imageView.frame = CGRectMake(0, 0, self.view.frame.size.width * 2, self.view.frame.size.height * 2);
imageView.contentMode = UIViewContentModeScaleToFill;
scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
[scrollView addSubview:imageView];
scrollView.contentSize = imageView.frame.size;
[self.view addSubview:imageView];
scrollView.delegate = self;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
scrollView.alpha = 0.5;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
scrollView.alpha = 1.0;
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
scrollView.alpha = 1.0;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.m
// UIWebView
//
// Created by hackeru on 10/05/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
{
WKWebView * webView;
}
- (void)viewDidLoad {
[super viewDidLoad];
WKPreferences * prefrences = [[WKPreferences alloc] init];
prefrences.javaScriptEnabled = YES;
WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc] init];
configuration.preferences = prefrences;
webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height - 35) configuration:configuration];
NSURL * url = [[NSURL alloc] initWithString:@"http://www.cnn.com"];
NSURLRequest * request = [[NSURLRequest alloc] initWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
webView.navigationDelegate = self;
}
-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.m
// UIProgressView
//
// Created by hackeru on 10/05/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
{
UIProgressView * progressView;
}
- (void)viewDidLoad {
[super viewDidLoad];
progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
progressView.center = self.view.center;
progressView.progress = 0.5;
progressView.trackTintColor = [UIColor greenColor];
progressView.tintColor = [UIColor blueColor];
[self.view addSubview:progressView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.m
// TableView (ListView)
//
// Created by hackeru on 10/05/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
{
UITableView * tableView;
}
- (void)viewDidLoad {
[super viewDidLoad];
tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
[tableView registerClass:UITableViewCell.class forCellReuseIdentifier:@"identifier"];
[tableView.dataSource = self;
[self.view addSubview:tableView];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
/*
There's no need to implement numberOfSectionsInTableView: because there's only one section and the method defaults to returning 1.
*/
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 100;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"identifier" forIndexPath:indexPath];
/*
Retrieve a cell with the given identifier from the table view.
The cell is defined in the main storyboard: its identifier is MyIdentifier, and its selection style is set to None.
*/
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identifier"];
}else{
}
// Set up the cell.
cell.textLabel.text = [NSString stringWithFormat:@"Row %li", indexPath.row];
return cell;
}
-(BOOL)prefersStatusBarHidden{
return YES;
}
-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end