How to have multiple proxy icons in Cocoa document windows? - objective-c

Most Cocoa applications, provided they call NSWindow's -setRepresentedFilename:, will display a nice little proxy icon at the top-centre of their NSWindows.
Here's an example of the Preview app with a PDF document:
Xcode, somehow, manages to display 2 proxy icons - one for the project file and the other for the current document in the source display.
Does anyone know how they do that? window:shouldPopUpDocumentPathMenu: in NSWindowDelegate seems very close - you could probably position your custom path menus with this. But there doesn't seem to be anything that would allow you to actually display the two proxy icons themselves.
Any ideas?

Unfortunately Apple has access to APIs the rest of us don’t. Messing with the title bar is really hard.
The best I can suggest is making your window NOT have a standard title bar, and then placing the buttons yourself by calling [self standardWindowButton:X] for each of the close, resize, and miniaturize buttons you want. Then place your own document icon and title textField.
You’ll likely have to track when the window loses or gains key or main status and modify the buttons accordingly (Cocoa fetches new buttons each time this happens, not sure why). Whee! Good luck!

Related

Cocoa Webview - Camouflage webview as native control

OK, I'm doing some experiments with WebView-based native OSX apps, and I'm wondering:
Which are the necessary steps in order to fully camouflage it? (So, that the user - ok, a non-technical user, actually) cannot possibly understand it's a webview.
How can we eliminate the right-click menu (including the "Reload" item)?
Last but not least:
If the actual webpage content is loaded on startup (in awakeFromNib), even for a simple webpage, it takes 1-or-2 seconds before the actual content shows up. During this time, a white/empty background shows where the webview/page should be. What could I do about that? Perhaps a "loading" indicator?
Any help will be appreciated! :-)
To eliminate the right click menu implement the webView(_:contextMenuItemsForElement:defaultMenuItems:) method of WebUIDelegate protocol.

Getting textual input from a menubar app? Cocoa

So I created a menubar app (agent application) and I need to find some way to get textual input via the menubar icon. I heard that making a popup modal with a textfield is frowned upon, and putting a text field in an NSMenuItem is bad for functionality. It doesn't even work, when I try.
You could use the new NSPopOver API in Lion. It will create a non-modal window anchored to a particular location, which seems to be exactly what you're looking for.

Best way to create floating notification iOS

I've got a tabbed iPad application with just about each tab running a UIWebView. I'm getting all sorts of callbacks, like when a user tries to leave the corporate site (which only displays the company site to users). In this case, I pop up a "toast" style window that tells them to click a button to open the page in Safari. I also pop it up with a spinner and no text to indicate that a page is loading. The approximate look that I'm going for is used in lots of applications, but you can see it best when changing the volume on the iPhone or iPad. It's just a translucent rounded square that fades in and out.
Right now I've got it implemented on one of my tabs, and I did it by creating the objects (a spinner, a label, and a UIImage with the square) and then programmatically hiding and showing them using [UIView beginAnimations] and changing the label's text. It works perfectly but I've got these nagging things hovering over my interface in Xcode, and it takes a lot of setup to accomplish if I wanted it to be in another tab, which I do. I can't help but think that there's a better way to accomplish this. I thought about making and adding a subview, but that would leave a white background to the toast. What I'm thinking is creating some sort of object that I can allocate in a tab's view controller whenever it's needed.
What are your guys ideas, or have you done this in the past? I see it in a lot of prominent applications, like Reeder, so I'm sure it's been done more eloquently than I have done it.
Matt Gallagher has a great class called LoadingView here Showing message over iPhone Keyboard. I use it.
MBProgressHUD is a popular library for this, as well.

How do I change the color of TableView and Button controls in iOS?

I designed a web app for iPhone and am now trying my hands at a native Objective-C version, and I'd like to retain some continuity with my original design. Since my web version uses CSS, I was able to customize the color palette, even though the UI was designed to imitate a native iPhone UI. I'd like to use a similar color scheme for my native app, but it doesn't seem so easy out of the box. I've gone through a couple tutorials and played around a bit with Interface Builder, inspecting the individual settings available for each control. My biggest questions are:
Is it possible to (or how do I) change the color of a Round Rect Button?
Is it possible to (or how do I) change the color of cells in a Table View?
Where in the Cocoa Touch Library can I find the standard iOS UI buttons, e.g. the green "Call Back" and red "Delete" buttons in the native voice mail?
Thanks
Nope, I don't think so. And you probably shouldn't anyways. In my opinion it's better to rather stay consistent with the OS and not the web... What you can do is to use a custom image.
UITableViewCell has a property named backgroundView, which is only present if you have a grouped style. This view has -- just like every other view -- a background color. If you don't have this and want to color individual cells, build a custom cell where you put in a view as background view.
As far as I know, they are not publicly available. However, you may find a lot of template images etc on the web that you can use.

How to create a Controller to simulate the Springboard feature of the iPhone within your own application

I am trying to design a feature in my application for the iPhone that simulates the Springboard feature (Main menu of the iPhone that allows you to view more apps), or the way Weather application works that allows you to flip between views.
Does anyone have any samples of this how I would go about doing this. It's seems very trivial but I am wondering if I am missing something that is already available either as an Apple example or someone who did a tutorial on this.
The image below show how the user would use it.
alt text http://www.agilitesoftware.com/SpringboardExample.png
As they slide their finger to the right (or left) the other image would begin to show up. And it would animate smoothly. The faster you swiped your finger the faster it would move to the next view.
Update: The other feature is that it should mimic the same feel when you slide your hand across the display that is snaps to the current view into place. It should not keep sliding across if there is more than 1 view to the direction you swiping your finger.
I've seen other applications use this so that is why I am asking.
This is accomplished using the UIScrollView with the pagingEnabled property set to true. Just add each of your views, adjust the contentSize, and it will automatically "page" to the width of the screen across the content.
There is a sample app (with code) with exactly this functionality on the iPhone developer site on Apple.com (I believe it's called "PageControl".) - I'd suggest checking it out.
d.
I'm writing an app that uses a similar UI. As NilObject recommended, we're using a UIScrollView with pagingEnabled=YES.
You may also be interested in this example code involving just two child views. I'm trying it out now; it's an interesting technique but I've had to write some additional special-casing code for some odd situations that resulted.
There's also another question on this site that asks about creating a grid of icons like the home screen.
I would check out Joe Hewitt's code from the Three20 project for this. It provides a nice interface and further refinement of the UIScrollView implemented as TTScrollView and TTScrollViewDelegate, TTScrollViewDataSource.