How to move legal link in mkmapview IOS 7 - ios7

as all we know Apple, we always need to change something for each update. Did somebody solve the moving problem for map legal link?
I tried many ways to control legal label but, just it can be hidden?
what else I can do?
thanks in advance

You need to change bottomLayoutGuide for your UIViewController. Create a class with following code:
MapLayoutGuide.h
#interface MapLayoutGuide : NSObject <UILayoutSupport>
-(id)initWithLength:(CGFloat)length;
#end
MapLayoutGuide.m
#import "MapLayoutGuide.h"
#implementation MapLayoutGuide
#synthesize length = _length;
- (id)initWithLength:(CGFloat)length
{
if (self = [super init])
{
_length = length;
}
return self;
}
#end
And then in your UIViewController, that is displaying map, add this:
-(id <UILayoutSupport>)bottomLayoutGuide
{
return [[MapLayoutGuide alloc] initWithLength:kMapViewBottomContentInset];
}
where kMapViewBottomContentInset - how much do you want to lift up Legal link. Typically size of UITabBar, if you have one.
This solution works even if you don't use AutoLayout on your view.

You can increase the height of the map so that the legal label is hidden by another view or something. I saw that some people placed a "locate me" button on top of it. I don't think that there is an easy (or legal) way to reposition or remove it.

override func viewWillLayoutSubviews() {
positionLegalMapLabel()
}
func positionLegalMapLabel() {
let legalMapLabel = self.mapView.subviews[1]
legalMapLabel.frame.origin = CGPointMake(self.mapView.bounds.size.width - legalMapLabel.frame.size.width - 7, legalMapLabel.frame.origin.y)
}

Related

NSScrollView how to start from top left corner

How to set scrollView document view to be pinned to top left corner? If scrollView is big enough/bigger than its content, everything is drawn from bottom to up and it not looks right. I have to override isFlipped of scrollView?
I was searching internet and overriding isFlipped to return trueis not everything. I don't want to make my documentView flipped because then I have to make changes in that class to make everything looks like I want.
I created simple NSView class as an container for elements that i want to have inside my scrollView and everything looks perfect. I hope this will help someone!
#interface FlippedView : NSView
#end
and implementation:
#implementation FlippedView
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
}
- (BOOL) isFlipped
{
return YES;
}
#end
Swift 4 Method to invert axises :
from https://stackoverflow.com/a/40381180/5464805 thank's to Ben Leggiero :
import Cocoa
class FlippedView: NSView {
override var isFlipped: Bool { return true }
}
Then in the storyboard, set this class to the NSView below the NSClipView and it do the trick.
However it won't appear in StoryBoard so you'll have to build and run

set placeholder for uitextview methods are not being called

I saw this answer of how to create a placeholder for UITextView.
I took the following steps:
Add to the .h class the declaration:
#interface AdjustPhotoViewController : UIViewController<UITextViewDelegate>
Added the method:
- (BOOL) textViewShouldBeginEditing:(UITextView *)textView
{
NSLog(#"%d",[textView tag]);
if ([textView tag]==1){
campaignTitle.text = #"";
}else{
campaignDescription.text = #"";
}
return YES;
}
But I don't see that the method is being invoked!
What am I missing?
textView is already delegated via the storyboard to the view
SOLVED:
The problem was that it wasn't delegated. Although I was using storyboard - it was only an outlet, not a delegate.
Remember that if you are using storyboard, you need to delegate also from the text view to the orange button of the view! not only the other way
What am I missing?
Actually setting the delegate.
textView.delegate = self;
Merely conforming to a protocol won't magically make your object into the delegate of an arbitrary object; that's just a formal thing, and anyways, how on Earth would the UITextField know which particular instance of the class it has to assign its delegate?

HOWTO: Is NSWindow In FullScreen Mode (Lion) AND Enabling/Disabling?

I spent a great deal of time figuring out how to determine if my NSWindow is in full screen mode or not and also how to enable/disable it from going in or out of full screen mode. This is useful when I am animating a view to another view or doing something where going into or out of full screen mode will mess stuff up. Sort of like locking down a window from being resized.
The answer to this is posted below.
For anyone interested here are some methods you can categorize or use as is. I spent some time looking for how to do this and thought it can help someone else out:
This one will tell you if you are or are not in full screen mode:
#implementation MyWindow
- (void) setStyleMask:(NSUInteger)styleMask {
MyWindowController *wndController = (MyWindowController *)self.windowController;
wndController.fullScreenMode = (styleMask & NSFullScreenWindowMask);
[super setStyleMask:styleMask];
}
#end
I am setting a property in my window controller.
For completeness here is what the category on NSWindow would look like:
#implementation NSWindow (CategoryNSWindow)
#pragma mark - Full Screen Mode:
- (BOOL) inFullScreenMode {
return (self.styleMask & NSFullScreenWindowMask);
}
#end
These two methods will enable / disable the ability to go into or out of full screen mode:
- (void) enableFullScreen {
NSWindowCollectionBehavior behavior = [self.window collectionBehavior];
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[self.window setCollectionBehavior:behavior];
}
- (void) disableFullScreen {
NSWindowCollectionBehavior behavior = [self.window collectionBehavior];
behavior ^= NSWindowCollectionBehaviorFullScreenPrimary;
[self.window setCollectionBehavior:behavior];
}
Rename methods as you please.
There are two events of NSWindowDelegate
DidWindowEnterFullScreen
DidWindowExitFullScreen
which help you solve your problem.
The two events of NSWindowDelegate are:
– windowDidEnterFullScreen:
– windowDidExitFullScreen:

Changing UIPickerView row height

I'm working on a program for a class I'm taking and part of the program requires a UIPickerView with images in it. I have the picker up and running, but the height of the rows in the picker are still too small, causing the images (100x100) to overlap. I'm looking for a way to change the UIPickerView so that the images will fit in one row, without overlapping. Thanks
In the documentation for the UIPickerView, you have a link to the UIPickerViewDelegate protocol. There is a method that you can implement, pickerView:rowHeightForComponent:.
use this method,provide default as a delegete method.
objective-C
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return 40;
}
In Swift:
func pickerView(pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat
{
return 40
}
for more visit : real world implementation

How do I respond to the user shaking an iPhone?

Alright, so to get going with Objective-C (I'm usually just an HTML PhoneGap kinda guy), I made a simple Magic 8 ball app. I've got it right now so that when I touch the screen, the ball "shakes" and takes a random response and puts it in a label. What I want to do is when the iPhone itself is shaked, the text is updated too.
Here's my MainView.m:
#import "MainView.h"
#implementation MainView
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
int rNumber = rand() % 26;
switch (rNumber) {
case 0:
shook.text = #"Never";
break;
....25 more entries.....
default:
break;
}
}
}
- (IBAction)yesNo {
[NSThread sleepForTimeInterval:0.75];
int rNumber = rand() % 26;
switch (rNumber) {
case 0:
result.text = #"Never";
break;
........
default:
break;
}
}
#end
and my MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#interface MainView : UIView <UIAccelerometerDelegate> {
IBOutlet UILabel *result;
IBOutlet UILabel *shook;
}
- (IBAction)yesNo;
- (void)motionEnded;
#end
Obviously there's an error in there, I know that much, but where?!
It looks like you need to read the documentation in more depth to get to the bottom of this. Specifically the iOS Event Handling Guide.
From that document there are a few things which I would suggest you try:
Override canBecomeFirstResponder: and return YES (as per Listing 4-1).
Override viewDidAppear:animated: to become the first responder (as per Listing 4-1).
Override both motionBegan:withEvent: and motionCancelled:withEvent: as they do this in the example which may be because the framework is testing your view controller class to see if it responds to these selectors (as per Listing 4-2).
Look at the UIResponder Class Reference (from which UIViewController inherits) for more detail on the methods you are overriding.
As someone who came from a Microsoft / VB / .NET and Android / Java background to Cocoa / Objective-C programming I would strongly suggest you invest the time in reading the documentation. Initially the Apple documents seem impenetrable but they're actually pretty good!
I hope that helps.