Restoring navigationItem.title after removing navigationItem.titleView - ios4

My App has 2 tabs (tabA and tabB), based on location the I set the navigationItem.titleView of tabB to a UIImageView when - viewWillAppear: is called.
The default behaviour of tabB is to simply display a title, e.g:
The issue is when the location changes and I remove the UIImageView navigationItem.titleView (using - removeFromSuperview), the default title has also disappeared and trying to set it with:
self.navigationItem.title = #"TITLE";
Does not work. Any ideas on how to solve this?

Simply setting:
navigationItem.titleView = nil;
Will restore the text title.

Related

Cannot select individual words with fixed layout .epub documents

I have a reader app that loads .epub files and usually I have no problem with selection at all, lately I have integrated fixed layout .epub files but I'm facing a problem: when I have a box containing one line the selection works fine, but when the box contains several lines, meaning several <p></p>, I cannot select a single word from the box. On selection the whole box gets selected as shown in the screenshot. When I try the same .epub file on iBooks, the selection works fine on all text. Any idea how I can fix the issue?
Here is the code for loading the file on UiWebView.
NSString *contents = [NSString stringWithContentsOfFile:itemPath encoding:NSUTF8StringEncoding error:nil];
if (!contents) {
contents = [NSString stringWithContentsOfFile:itemPath encoding:NSASCIIStringEncoding error:nil];
}
[readingWebView loadHTMLString:contents baseURL:baseURL];
I have finally got the answer.
When using this function:
NSString *jsString = [NSString stringWithFormat:#"document.getElementsByTagName('body')[0].webkitTextSizeAdjust= '%d%%'", font];
to set the font size some restrictions are set on the web view, one of them is related to the selection with fixed layout epubs.
I used instead:
NSString *jsString = [NSString stringWithFormat:#"document.getElementsByTagName('body')[0].style.fontSize= '%d%%'", font];

subclass NSWindowController Core Data

I have a newb question, which I have tried unsuccessfully to find answers for on the web. The task is simple: I want to create a core data document-based app but alter the values in some label objects. Using interface builder, I can build the core data model and populate it, using an array controller, table, etc. all without writing any code. So far so good. My test example is to build a core data model with Box entities that have length and width attributes. I would like a label to display the area, i.e. length*width for any geometrically challenged :).
So after browsing around, I've decided I need to create an NSWindowController subclass and use that to update the label when a box in the table is selected. Have attempted this, but have failed. Before I even hook up the label to the window controller, I have a problem. Following the template comments, I added this to Document.m:
- (void)makeWindowControllers
{
NSLog(#"Adding custom Window Controller");
MyWindowController* myWindowController = [[MyWindowController alloc] init];
[self addWindowController:myWindowController];
}
Also added this to the template MyWindowController.m:
- (id)init
{
self = [super initWithWindowNibName:#"MyWindowController"];
return self;
}
The window controller has its own NIB file from Interface builder where I put the table and label etc. The file owner is set to MyWindowController. Probably forgetting other things, but that's what I remember for now.
The log message appears at startup, but then I get an exception "this class is not key value coding-compliant for the key managedObjectContext" before the window appears. I'm guessing that I don't have the window controller hooked up to the document class properly? My other thought is that the array controller is in the window controller nib, not the document nib, so maybe it's looking in the wrong place for the managedObjectContext?
I would try a different approach: Add area to your Box entity as a read-only attribute. Auto-create a Box class with Xcode ("Create NSManagedObject Subclass" menu item in the "Editor" menu when viewing the data model), then add this to Box.h
#property (weak, readonly) NSString * area;
and this to Box.m
- (NSNumber *)area
{
return [NSNumber numberWithDouble:([[self length] doubleValue] - [[self width] doubleValue])];
}
+ (NSSet *)keyPathsForValuesAffectingArea
{
return [NSSet setWithObjects:#"length", #"width", nil];
}
If you do this you can just bind area to a label value like you do for the other Box properties. No need to subclass NSWindowController or watch for changes.

javafx 2.0 TitledPane how to change the title text to image+text

the default title only contains text, just like the "Apples" title in the above image.
is that possible to add image in the title.
or
is there a way developer can build a customized TitledPane ?
thanks
Use setGraphic method
TitledPane tp = new TitledPane("hi");
tp.setGraphic(new Rectangle(10, 10));
As far as I know, you can set the graphics via the css property "-fx-graphic" as well.
See Oracle Defintion for JFX and CSS, here for elements of type Labeled.
To remove the button completely, you could either
set tp.setCollabsible(false); or
use the .titled-pane CSS class to set the property "-fx-collapsible" to false.
See Here (same side as above, but for TitledPane).

What must be done to migrate from Storyboard back to XIBs for iOS 4.x support?

I have seen scattered information related to this subject across stackoverflow and other sites, but nothing comprehensive. I've wasted hours upon hours trying to get this to work to no avail. However, I see in this post on stackoverflow (http://stackoverflow.com/questions/7909906/extracting-nibs-xibs-from-storyboards-ios), but nothing with step by step details.
I have only a single view controller (HomeViewController) in my storyboard, and it is extended from a navigation controller.
Can someone please help me identify exactly what all needs to happen to make this work?
Please correct me, add to, etc to make these steps correct:
Create a new XIB (say, HomeViewController.xib)
Copy all items from the storyboard's view controller into this xib
Set the Class type for the view controller to be HomeViewController class.
Hook up all of the IBOutlets and IBActions.
?? - Should I make the xib contain a navigation controller which contains the UIViewController, or should I set the File's Owner to the HomeViewController class??
Add new Window property in the AppDelegate class.
Create a new MainWindow.xib. What setup needs to happen here? (a) File's Owner to UIApplication; (b) Drag new Object to the "Objects" panel and set it's class to my AppDelegate class; (c) Drag new Window to the "Objects" panel; (d) Connect the IBOutlet for the AppDelegate Window property to this new window object.
Go to the project settings (click on the project in the Project Navigation tab, select the target), and clear the "Main Storyboard" field and set the Main Interface to what? HomeViewController? Or Main Window?
Make the change in the AppDelegate class as shown below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
This is all I know to do, but it still doesn't work. What am I missing?

My Main Window will not change even though I change it?

Hey!
Have a problem that is driving me crazy! My Main Window will not change when a make changes in interface builder in xcode 4, I have played around for over 2 hours trying to make changes but when a build it does not change. When a change something in the code it works just fine.
The thing I'm trying to add to the main window is a new tab in the tabbar.
Please help me !
UPDATE:
My applictiondidfinfishwithoptions looks like this.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[window addSubview:navigationController.view];
[window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
Make sure that you are adding the tab to whatever view is assigned to the main window's root view controller property. If you drag and item into the window itself it won't work. To complicate matters, some of Apple's templates configure the root view controller in the application delegate's application:didFinishLaunchingWithOptions: method, so check there to see what is being assigned.
UPDATE:
You should add one view to the window and add the other views as subviews.

Resources