Adding three subviews each with Navigationcontroller Stupid? - xcode

Hello i created three books(UIViews) each with it's own Navigationcontroller for paging.
My questions
!) Does it make any sense to use three Navigationcontroller
2) Is my code below any good? It seems to work but the bar has a ofset of 20px from the top.
#import "Book_01.h"
#implementation Book_01 // UIViewController
#synthesize book_01_NavigationController;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
[self.view addSubview:book_01_NavigationController.view];
}
return self;
}

Man, your code it's okei. But, you need to declare your navigation controller first:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
book_01_NavigationController = [[UINavigationController alloc] initWithRootViewController:self];
[self.view addSubview:book_01_NavigationController.view];
}
return self;
}
About ofset of 20px from the top. That's because your status bar it's hidden. You need to adjust the elements to fullscreen.
[]'S

Related

DRPaginatedScrollView - View not rendered

Quite new to Xcode UI, I'm trying to use the nice & small pod DRPaginatedScrollView.
This pod allows to scroll between multiple views.
Here is what I did
Added a View Controller to my storyboard
Created a UIViewController subclass
Pointed my View Controller to the class
Here is the content of my class:
#implementation MyViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBoNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBoNil];
if (self) {
self.paginatedScrollView = [DRPaginatedScrollView new];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self setup];
[self setupView];
}
- (void)setup {
NSLog(#"Setup");
[self.paginatedScrollView addPageWithHandler:^(UIView *pageView) {
NSLog(#"Handler");
UIView * square = [UIView new];
[square setBackgroundColor:[UIColor redColor]];
[square setFrame:CGRectMake(0, 0, 100, 100)];
[pageView addSubview:square];
}];
}
- (void)setupView {
[self.view insertSubview:self.paginatedScrollView atIndex:0];
NSLog(#"Nb pages: [%ld]", (long)[self.paginatedScrollView numberOfPages]);
}
#end
My log shows only
2014-06-17 12:10:14.113 my_proj[6018:60b] Setup
2014-06-17 12:10:14.115 my_proj[6018:60b] Number of pages: [0]
My main view remains blank, "Handler" is not logged, DRPaginatedScrollView is counting 0 page.
Am I forgetting something ?
I just realized initWithNibName was never called (I don't understand why), so I initialized paginatedScrollView from viewDidLoad, now it's well initialized but still no render.
I did not set DRPaginatedScrollView's frame size:
CGRect frameRect = self.paginatedScrollView.frame;
frameRect.size.width = self.view.frame.size.width;
frameRect.size.height = self.view.frame.size.height;
self.paginatedScrollView.frame = frameRect;

iPhone SDK: Buttons and Labels causing UIScrollView to not scroll

I have been dealing with this all day and I simply cant find what the heck is going wrong. I have a scrollview inside a viewcontroller, but when i add a label or button to the view the scroll view stops scrolling. This is so standard i've done it hundred of times but for some reason its acting up now. Hope someone can help.
.h
#interface Test : UIViewController{
IBOutlet UIScrollView *scrollView;
}
-(IBAction)goBack;
#end
.m
#interface Test ()
#end
#implementation Test
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
scrollView.contentSize=CGSizeMake(320.0,1100.0);
}
-(IBAction)goBack
{
[self dismissModalViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end

Allow to view image in landscape in portrait-only app

I am making an iPhone and iPod app that I will make in portrait mode only. There comes a point in the app where if the user touches a picture, it will make itself fullscreen. The way I do that is via a segue to another view controller, where a UIImageView takes the whole space. I would like to be able to rotate the device in landscape to view the picture in landscape.
How it that possible?
In a second phase: I would like to know how to make the view fullscreen, so the picture could fill the entire screen.
Basically: I want the picture to behave just like the twitter app. :)
Thanks
EDIT: here is the code in my Class to view the image
#import "ImageViewer.h"
#interface ImageViewer ()
#end
#implementation ImageViewer
#synthesize scrollView;
#synthesize imageView;
#synthesize image;
- (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.
CGRect imageFrame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
self.imageView.frame = imageFrame;
self.scrollView.contentSize = imageFrame.size;
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *)sender
{
return self.imageView;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(#"rotate.");
return YES;
}
- (void)viewDidUnload {
[self setImageView:nil];
[self setScrollView:nil];
[super viewDidUnload];
}
#end

A Button to make a TextView from invisible to visible

iam a newbie in Xcode programming and i didnt find the right answer in another Tread.
My Question: I have a Detailview with a CardQuestion(TextView) and a CardAnser(TextView).
How is the method to change the invisible Answer to visible.
On Action the Button "Show Answer".
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = self.chosenCard.name;
self.cardName.text = self.chosenCard.name;
self.cardQuestion.text = self.chosenCard.question;
self.cardAnswer.text = self.chosenCard.answer;
}
- (void)viewDidUnload
{
[self setCardName:nil];
[self setCardQuestion:nil];
[self setCardAnswer:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (IBAction)toAnswerButton:(id)sender{
}
#end
I hope you can understand my question.
UIView subviews (including UILabel, UITextField and UITextView) have a hidden property. Set that to YES to hide a view and to NO to unhide it. You can also set this property in Interface Builder.

Is this a bug for EKEventEditViewController

I found EKEventEditViewController is not correct in
UIInterfaceOrientationPortraitUpside.
Try this demo from your site, I just changed code as below, put simulator to
UpSide Down Portrait mode, then click "+" button, you will find the screen in
flash, this is due to dialog is upside in short time.
Then you can try it on device turn to UpSideDown mode, you will see what I am talking:)
I want to know why they have different view in Simulator or iPad even if it is
not a bug.
Bug in SimpleEKDemo
Basically you would want to Create your own class that inherits from EKEventEditViewController and use that everywhere you would use normally use EKEventEditViewController. For example, KonopEventEditViewController.
KonopEventEditViewController.h is as follows
#import <EventKitUI/EventKitUI.h>
#interface KonopEventEditViewController : EKEventEditViewController
#end
KonopEventEditViewController.m is as follows
#import "KonopEventEditViewController.h"
#interface KonopEventEditViewController ()
#end
#implementation KonopEventEditViewController
- (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.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
#end

Resources