Is this a bug for EKEventEditViewController - events

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

Related

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

How to change value in UISegmentedControl?

I have set up a segmented control in my project. I want to use it in my settings scene to control whether the orientation is landscape left or landscape right. I have in set up in my storyboard and here is my code in my SettingsViewController.h
#import <UIKit/UIKit.h>
#interface SettingsViewController : UIViewController
{
IBOutlet UISegmentedControl *orientation;
}
#property (nonatomic, retain) UISegmentedControl *orientation;
- (IBAction) setOrientation;
#end
and here is my code in SettingsViewController.m
#import "SettingsViewController.h"
#implementation SettingsViewController
#synthesize orientation;
- (IBAction)setOrientation
{
NSLog(#"index = %d\n", orientation.selectedSegmentIndex);
if (orientation.selectedSegmentIndex == 0) {
NSLog(#"left\n");
}
if (orientation.selectedSegmentIndex == 1) {
NSLog(#"right\n");
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
#end
I was wondering why the value isn't changing from 0 to 1 when I select the right side of the control. Also I was wondering if in my .h I need to declare IBOutlet because I dont use the segmented control as an outlet. I just use it to take in which side is selected and then use that to set the orientation of the app.
Try this. Hook it up in the Storyboard to the segmentedControl using valueChanged.
- (IBAction)segmentedControlChanged:(id)sender {
UISegmentedControl *segmentedC = (UISegmentedControl *)sender;
if (segmentedC.selectedSegmentIndex == 0) {
// NSLog(#"selectedSegmentIndex == 0");
[self selectFirstSegment];
}
}
in segment action set the orientation landscape or potriat..and in .m file end of bool orientation type method set
return yes;
in all .m files .

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.

How can I use shake gesture when using storyboards?

I've made an application where you shake the phone to open a new view. All together three views, and when you shake the phone on the last view you go back to the first screen. This works fine when I'm creating new subclass controls view with their own .xib. But I would like to use this in a storyboard project, what do I need to change?
Thanks a lot on beforehand!
HERE IS THE CODE IN .H:
#import <UIKit/UIKit.h>
#import "FirstScreenViewController.h"
#import "SecondScreenViewController.h"
#interface ViewController : UIViewController
{
NSInteger currentScreen;
UIViewController* currentController;
}
#end
AND HERE IN THE .M:
#import "ViewController.h"
#implementation ViewController
-(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark shake
-(BOOL)canBecomeFirstResponder
{
return true;
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if(motion == UIEventSubtypeMotionShake)
{
if (currentController)
{
[currentController.view removeFromSuperview];
currentController=nil;
}
switch (currentScreen)
{
case 0:
currentController = [[FirstScreenViewController alloc] initWithNibName:#"FirstScreenViewController" bundle:nil];
break;
case 1:
currentController = [[SecondScreenViewController alloc] initWithNibName:#"SecondScreenViewController" bundle:nil];
}
if(currentController)
{
[currentController.view setFrame:self.view.bounds];
[self.view addSubview:currentController.view];
}
currentScreen++;
if(currentScreen >2)
currentScreen=0;
}
}
#pragma mark - View lifecycle
-(void)viewDidLoad
{
[super viewDidLoad];
currentScreen = 0;
}
-(void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
#end
You need to add all three view controllers to the storyboard, and have segues between them (including one back to the first from the third) and a shake gesture recogniser attached to each scene.
The action method for each gesture recogniser tells the view controller to performSegue: with the appropriate segue identifier.

Resources