Search Results

Search found 1485 results on 60 pages for 'dan heyse'.

Page 28/60 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • UIView Controller mysteriously getting deallocated

    - by Dan Ray
    I have a UINavigation scheme with a "welcome" page, a middle page, and a detail page. In the middle page, there's a segmented controller that can swap the main body of that page between a table, a calendar, and a MKMapView, each implemented with their own view controller classes. Today I implemented the MapView and its annotations and all of that. It's nice. And a detail disclosure on each callout takes you to the detail page just the same way as if you'd gotten there via the table. Lovely. I also have a right-button-bar button that pushes in a "search" view. From there you can search the data I'm navigating. When it's done filtering the data (an array of objects I'm keeping in a data singleton), it makes the table reload its data, and calls my annotation-clearer-and-builder methods on the map view, and then pops itself out, so the "middle" page (including whatever view was in the guts of it) is back on the screen. Problem is, if I go back and forth between the map and the search a couple times, any mention of the table view causes us to crash with: *** -[CALayer retain]: message sent to deallocated instance 0x710b810. (I obviously have NSZombies turned on.) I put an NSLog in the dealloc method of my table view controller. That thing's never getting called. I don't know if we're ditching it behind the scenes for memory purposes, or if I'm leaking it and can't get my hands back on it, or what. I'm sort of at a loss about where to look. Any hints?

    Read the article

  • Amazon EC2 EBS automatic backup one-liner works manually but not from cron

    - by dan
    I am trying to implement an automatic backup system for my EBS on Amazon AWS. When I run this command as ec2-user: /opt/aws/bin/ec2-create-snapshot --region us-east-1 -K /home/ec2-user/pk.pem -C /home/ec2-user/cert.pem -d "vol-******** snapshot" vol-******** everything works fine. But if I add this line into /etc/crontab and restart the crond service: 15 12 * * * ec2-user /opt/aws/bin/ec2-create-snapshot --region us-east-1 -K /home/ec2-user/pk.pem -C /home/ec2-user/cert.pem -d "vol-******** snapshot" vol-******** that doesn't work. I checked var/log/cron and there is this line, therefore the command gets executed: Dec 13 12:15:01 ip-10-204-111-94 CROND[4201]: (ec2-user) CMD (/opt/aws/bin/ec2-create-snapshot --region us-east-1 -K /home/ec2-user/pk.pem -C /home/ec2-user/cert.pem -d "vol-******** snapshot" vol-******** ) Can you please help me to troubleshoot the problem? I guess is some environment problem - maybe the lack of some variable. If that's the case I don't know what to do about it. Thanks.

    Read the article

  • Can iptables allow Squid to process a request, then redirect the response packets to another port?

    - by Dan H
    I'm trying to test a fancy traffic analyzer app, which I have running on port 8890. My current plan is to let any HTTP request come into Squid, on port 3128, and let it process the request, and then just before it sends the response back, use iptables to redirect the response packets (leaving port 3128) to port 8890. I've researched this all night, and tried many iptables commands, but I'm missing something and my hair is falling out. Is this even possible? If so, what iptables incantation could do it? If not, any idea what might work on a single host, given multiple remote browser clients?

    Read the article

  • Using Tkinter in python to edit the title bar

    - by Dan
    I am trying to add a custom title to a window but I am having troubles with it. I know my code isn't right but when I run it, it creates 2 windows instead, one with just the title tk and another bigger window with "Simple Prog". How do I make it so that the tk window has the title "Simple Prog" instead of having a new additional window. I dont think I'm suppose to have the Tk() part because when i have that in my complete code, there's an error from tkinter import Tk, Button, Frame, Entry, END class ABC(Frame): def __init__(self,parent=None): Frame.__init__(self,parent) self.parent = parent self.pack() ABC.make_widgets(self) def make_widgets(self): self.root = Tk() self.root.title("Simple Prog")

    Read the article

  • How do I Resolve dependancies that rely on transient context data using castle windsor?

    - by Dan Ryan
    I have a WCF service application that uses a component called EnvironmentConfiguration that holds configuration information for my application. I am converting this service so that it can be used by different applications that have different configuration requirements. I want to identify the configuration to use by allowing an additional parameter to be passed to the service call i.e. public void DoSomething(string originalParameter, string callingApplication) What is the recommended way to alter the behaviour of the EnvironmentConfiguration class based on the transient data (callingApplication) without having to pass the callingApplication variable to all the component methods that need configuration information?

    Read the article

  • CSS - Opaque text on low opacity div?

    - by Dan
    Hi, I have a div with 60% opacity, to show part of a background image behind the div. Because the opacity is at 60%, the text in that div appears as grey. Is there anyway to override this level and make the text appear black? Any advice appreciated. Thanks.

    Read the article

  • How do I change variables from different classes?

    - by Dan T
    Before I delve into it, I'm very new to Android and I have just started learning Java last month. I've hit bumps while trying to develop my first simple app. Most of these hurdles were jumped thanks to random tutorials online. MY CODE IS VERY MESSY. Any tips are appreciated. The question above is quite broad, but this is what I want to do: It's a essentially a blood alcohol content calculator / drink keeper-tracker. Basic layout: http://i.imgur.com/JGuh7.jpg The buttons along the bottom are just regular buttons, not ImageButtons (had problems with that) Here's some example code of one: <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_marginRight="5dp" android:background="@drawable/addbeer"/> The buttons and TextView are all in main.xml. I have variables defined in a class called Global.java: package com.dantoth.drinkingbuddy; import android.app.Activity; public class Global extends Activity{ public static double StandardDrinks = 0; public static double BeerOunces = 12; public static double BeerPercentAlcohol = .05; public static double BeerDrink = BeerOunces * BeerPercentAlcohol; public static double BeerDrinkFinal = BeerDrink * 1.6666666; public static double ShotOunces = 1.5; public static double ShotPercentAlcohol = .4; public static double ShotDrink = ShotOunces * ShotPercentAlcohol; public static double ShotDrinkFinal = ShotDrink * 1.6666666; public static double WineOunces = 5; public static double WinePercentAlcohol = .12; public static double WineDrink = WineOunces * WinePercentAlcohol; public static double WineDrinkFinal = WineDrink * 1.6666666; public static double OtherOunces; public static double OtherPercentAlcohol; public static double OtherDrink = OtherOunces * (OtherPercentAlcohol * .01); public static double OtherDrinkFinal = OtherDrink * 1.6666666; public static double GenderConstant = 7.5; //9 for female public static double Weight = 180; public static double TimeDrinking = 60; public static double Hours = TimeDrinking / 60; public static double Bac = ((StandardDrinks / 2) * (GenderConstant / Weight)) - (0.017 * Hours); } The last variable is the important part. It calculates your BAC based on the factors involved. When I press the add beer button (Button01) I make it add 1 to StandardDrinks, simulating drinking one beer. The other variables in the Bac formula have values assigned to them in Global.java. The code that makes the beer button do stuff is in my regular class, drinkingbuddy.java: public class DrinkingBuddy extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.Button01); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Global.StandardDrinks = Global.StandardDrinks + Global.BeerDrinkFinal; Toast.makeText(DrinkingBuddy.this, "Mmmm... Beer", Toast.LENGTH_SHORT).show(); } }); By my perception, StandardDrinks should now have a value of 1. However, when I click the Calculate BAC button (Button05) it merely outputs the variable Bac as if StandardDrinks was still set to 0. Here is the code for the Calculate BAC button (Button05): Button button4 = (Button) findViewById(R.id.Button05); button4.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TextView texty; texty = (TextView) findViewById(R.id.texty1); texty.setText("Your BAC is " + Global.Bac ); } }); It outputs the following to the text view: "Your BAC is -0.017". This is the Bac value for if StandardDrinks was still 0, so obviously there is some problem communicating between the classes. Can anyone help me?? The other elements of the formula (weight, time spent drinking, and the alcohol %'s and such) are variables because I will ultimately allow the user to change those values in the settings. I've heard around the water cooler that global variables are not good programming style, but this is the closest I've come to getting it to work. Any other ways of doing it are very much welcomed!

    Read the article

  • Need to calculate offsetRight in javascript

    - by Dan Bailiff
    I need to calculate the offsetRight of a DOM object. I already have some rather simple code for getting the offsetLeft, but there is no javascript offsetRight property. If I add the offsetLeft and offsetWidth, will that work? Or is there a better way? function getOffsetLeft(obj) { if(obj == null) return 0; var offsetLeft = 0; var tmp = obj; while(tmp != null) { offsetLeft += tmp.offsetLeft; tmp = tmp.offsetParent; } return offsetLeft; } function getOffsetRight(obj) { if (obj == null) return 0; var offsetRight = 0; var tmp = obj; while (tmp != null) { offsetRight += tmp.offsetLeft + tmp.offsetWidth; tmp = tmp.offsetParent; } return offsetRight; }

    Read the article

  • weakref list in python

    - by Dan
    I'm in need of a list of weak references that deletes items when they die. Currently the only way I have of doing this is to keep flushing the list (removing dead references manually). I'm aware there's a WeakKeyDictionary and a WeakValueDictionary, but I'm really after a WeakList, is there a way of doing this? Here's an example: import weakref class A(object): def __init__(self): pass class B(object): def __init__(self): self._references = [] def addReference(self, obj): self._references.append(weakref.ref(obj)) def flush(self): toRemove = [] for ref in self._references: if ref() is None: toRemove.append(ref) for item in toRemove: self._references.remove(item) b = B() a1 = A() b.addReference(a1) a2 = A() b.addReference(a2) del a1 b.flush() del a2 b.flush()

    Read the article

  • Passing Variables between views / view controllers

    - by Dan
    Hi I'm new to ObjectiveC / IPhoneSDK and I'm informally trying to study it on my own. What I'm basically trying to do is from one view there are 12 zodiac signs. When a user clicks one, it proceeds to the second view (with animation) and loads the name of the zodiac sign it clicked in a UILabel, that's it. Here are my codes: Lovescopes = 1st page Horoscopes = 2nd page Lovescopes4AppDelegate.h #import <UIKit/UIKit.h> #import "HoroscopesViewController.h" #import "Lovescopes4AppDelegate.h" @class Lovescopes4ViewController; @interface Lovescopes4AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; Lovescopes4ViewController *viewController; HoroscopesViewController *horoscopesViewController; } -(void)loadHoroscope; -(void)loadMainPage; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet Lovescopes4ViewController *viewController; @property (nonatomic, retain) HoroscopesViewController *horoscopesViewController; @end Lovescopes4AppDelegate.m #import "Lovescopes4AppDelegate.h" #import "Lovescopes4ViewController.h" @implementation Lovescopes4AppDelegate @synthesize window; @synthesize viewController; @synthesize horoscopesViewController; -(void)loadHoroscope { HoroscopesViewController *aHoroscopeViewController = [[HoroscopesViewController alloc] initWithNibName:@"HoroscopesViewController" bundle:nil]; [self setHoroscopesViewController:aHoroscopeViewController]; [aHoroscopeViewController release]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; [viewController.view removeFromSuperview]; [self.window addSubview:[horoscopesViewController view]]; [UIView commitAnimations]; } -(void)loadMainPage { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:NO]; [horoscopesViewController.view removeFromSuperview]; [self.window addSubview:[viewController view]]; [UIView commitAnimations]; [horoscopesViewController release]; horoscopesViewController = nil; } - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end Lovescopes4ViewController.h #import <UIKit/UIKit.h> #import "HoroscopesViewController.h" @interface Lovescopes4ViewController : UIViewController { HoroscopesViewController *hvc; } -(IBAction)loadAries; @property (nonatomic, retain) HoroscopesViewController *hvc; @end Lovescope4ViewController.m #import "Lovescopes4ViewController.h" #import "Lovescopes4AppDelegate.h" @implementation Lovescopes4ViewController @synthesize hvc; -(IBAction)loadAries { NSString *selected =@"Aries"; [hvc loadZodiac:selected]; Lovescopes4AppDelegate *mainDelegate = (Lovescopes4AppDelegate *) [[UIApplication sharedApplication] delegate]; [mainDelegate loadHoroscope]; } HoroscopesViewController.h #import <UIKit/UIKit.h> @interface HoroscopesViewController : UIViewController { IBOutlet UILabel *zodiacLabel; } -(void)loadZodiac:(id)zodiacSign; -(IBAction)back; @property (nonatomic, retain) IBOutlet UILabel *zodiacLabel; @end HoroscopesViewController.m #import "HoroscopesViewController.h" #import "Lovescopes4AppDelegate.h" @implementation HoroscopesViewController @synthesize zodiacLabel; /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; } */ /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } */ /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ -(void)loadZodiac:(id)zodiacSign { zodiacLabel.text = [NSString stringWithFormat: @"%@", zodiacSign]; } -(IBAction)back { Lovescopes4AppDelegate *mainDelegate = (Lovescopes4AppDelegate *) [[UIApplication sharedApplication] delegate]; [mainDelegate loadMainPage]; }

    Read the article

  • Avoiding CheckStyle magic number errors in JDBC queries.

    - by Dan
    Hello, I am working on a group project for class and we are trying out CheckStyle. I am fairly comfortable with Java but have never touched JDBC or done any database work before this. I was wondering if there is an elegant way to avoid magic number errors in preparedStatement calls, consider: preparedStatement = connect.prepareStatement("INSERT INTO shows " + "(showid, showtitle, showinfo, genre, youtube)" + "values (default, ?, ?, ?, ?);"); preparedStatement.setString(1, title); preparedStatement.setString(2, info); preparedStatement.setString(3, genre); preparedStatement.setString(4, youtube); result = preparedStatement.executeUpdate(); The setString methods get flagged as magic numbers, so far I just added the numbers 3-10 or so to the ignore list for magic numbers but I was wondering if there was a better way to go about inserting those values into the statement. I also beg you for any other advice that comes to mind seeing that code, I'd like to avoid developing any nasty habits, e.g. should I be using Statement or is PreparedStatement fine? Will that let me refer to column names instead? Is that ideal? etc... Thanks!

    Read the article

  • ctags doesn't work when class is defined like "class Gem::SystemExitException"

    - by dan
    You can define a class in a namespace like this class Gem class SystemExitException end end or class Gem::SystemExitException end When code uses first method of class definition, ctags indexes the class definition like this: SystemExitException test_class.rb /^ class SystemExitException$/;" c class:Gem With the second way, ctags indexes it like this: Gem rubygems/exceptions.rb /^class Gem::SystemExitException < SystemExit$/;" c The problem with the second way is that you can't put your cursor (in vim) over a reference to "Gem::SystemExitException" and have that jump straight to the class definition. Your only recourse is to page through all the (110!) class definitions that start with "Gem::" and find the one you're looking for. Does anyone know of a workaround? Maybe I should report this to the maintainer of ctags?

    Read the article

  • Windows Server 2008 on VPC (Host: Win 7)?

    - by Dan
    Is it possible to test Windows 2008 server via VPC when my host of a Windows 7 machine? I don't see anywhere where it says this is possible? The only VPC images (Windows 2008 R2) that I download from Microsoft state that the host machine must be Windows 2008. Is there an alternative?

    Read the article

  • Managing execution priorities and request expiry time in your web application

    - by Dan
    Some installations that run our applications can be under hefty stress on a busy day. Our clients ask us is there is a way to manage priorities in our application. For example, in a typical internet banking application, banks are interested in having the form “Transfer money” responsive, while the “Statement” page is a lot less critical. Not being able to transfer money is a direct loss for the bank, while not being able to produce a statement or something similar can be fixed with an apology. AFAIK, neither can you manage different request or session timeouts in a typical web application, it is one value for the whole of your web app. Managing message priority and expiry time is a typical feature in many middleware platforms. Something like this can be useful for a web front end as well. Do any of web servers (either java or .net) or web frameworks provide these features? How would you go about implementing it if you’d have to go for roll-your-own?

    Read the article

  • VS2010 on XP SP3 64 bit

    - by Dan B
    Hello, We are soon to get VS2010 and according to the link below, Microsoft do not support VS2010 on XP x64. http://www.microsoft.com/visualstudio/en-us/products/2010-editions/professional/system-requirements Does anyone have XP 64bit running VS2010? I am not interested in 64bit version of VS (I am wanting to install a 32bit version of VS2010 professional on a 64 bit XP machine). I am aware that XP will require SP3. Any warnings? Horror stories? Advice?

    Read the article

  • How to get R to recognize your working directory as its working directory?

    - by Dan Goldstein
    I use R under Windows on several machines. I know you can set the working directory from within an R script, like this setwd("C:/Documents and Settings/username/My Documents/x/y/z") ... but then this breaks the portability of the script. It's also annoying to have to reverse all the slashes (since Windows gives you backslashes) Is there a way to start R in a particular working directory so that you don't need to do this at the script level?

    Read the article

  • How do I close a database connection being used to produce a streaming result in a WCF service?

    - by Dan
    I have been unable to find any documentation on properly closing database connections in WCF service operations. I have a service that returns a streamed response through the following method. public virtual Message GetData() { string sqlString = BuildSqlString(); SqlConnection conn = Utils.GetConnection(); SqlCommand cmd = new SqlCommand(sqlString, conn); XmlReader xr = cmd.ExecuteXmlReader(); Message msg = Message.CreateMessage( OperationContext.Current.IncomingMessageVersion, GetResponseAction(), xr); return msg; } I cannot close the connection within the method or the streaming of the response message will be terminated. Since control returns to the WCF system after the completion of that method, I don't know how I can close that connection afterwards. Any suggestions or pointers to additional documentation would be appreciated.

    Read the article

  • Dealing with unwanted port numbers on localhost when debugging in Visual Studio

    - by Dan Bailiff
    So when I'm trying to debug a project in Visual Studio, I'll often have 1 or more services that I need to call. These services are separate projects and I'll launch them in separate instances of VS. ASP dev server kindly launches them with temporary port numbers attached. This would be fine except for my programs are looking for an IP without a port attached. (Typically it's as simple as "localhost"!) I've coped by using web config settings and changing the xml to use the port number while debugging. This still doesn't always work and occasionally I'll still have to fudge it and insert port numbers as strings in code! UGH! Then I have to remember to undo all the port herding code before deployment... I want to stop doing this: string _strBaseURL = String.Format("http://{0}:2277", ConfigurationManager.AppSettings["myservice_ip"].ToString()); What is the best practice here? Am I doomed to port herding while debugging VS apps?

    Read the article

  • How to manually add a legend to a ggplot object

    - by Dan
    I have this data frame: structure(list(month_num = 1:24, founded_month = c(4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L), founded_year = c(2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2010L, 2010L, 2010L), count = c(270L, 222L, 256L, 250L, 277L, 268L, 246L, 214L, 167L, 408L, 201L, 225L, 203L, 220L, 230L, 225L, 177L, 207L, 166L, 135L, 116L, 122L, 69L, 42L), month_abb = c("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar"), short_year = c("08", "08", "08", "08", "08", "08", "08", "08", "08", "09", "09", "09", "09", "09", "09", "09", "09", "09", "09", "09", "09", "10", "10", "10" ), proj = c(282, 246, 292, 298, 337, 340, 330, 310, 275, 528, 333, 369, 359, 388, 410, 417, 381, 423, 394, 375, 368, 386, 345, 330), label = c("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan\n09", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan\n10", "Feb", "Mar")), .Names = c("month_num", "founded_month", "founded_year", "count", "month_abb", "short_year", "proj", "label"), row.names = c(NA, -24L), class = "data.frame") and i've got all of this done (I know the code's a bit ugly looking, pointers appreciated): p <- ggplot(m_summary2, aes(x = month_num, y = count)) p + geom_line(colour = rgb(0/255, 172/255, 0/255)) + geom_point(colour = rgb(0/255, 172/255, 0/255)) + geom_line(aes(x = m_summary2$month_num, y = m_summary2$proj), colour = rgb(18/255, 111/255, 150/255)) + geom_point(aes(x = m_summary2$month_num, y = m_summary2$proj), colour = rgb(18/255, 111/255, 150/255)) + scale_x_continuous("Month", breaks = m_summary2$month_num, labels = m_summary2$label) + scale_y_continuous("# Startups Founded") + opts(title = paste("# Startups Founded:", m_summary2$month_abb[1], m_summary2$short_year[1], "-", m_summary2$month_abb[nrow(m_summary2)], m_summary2$short_year[nrow(m_summary2)])) Now I would like to add a legend to clarify that the blue line is a projection and the green line is the current data. Thanks in advance!

    Read the article

  • How to login to youtube from php?

    - by dan
    Hi, I want to use the youtube api to get the users new subscription videos with this api call: http://gdata.youtube.com/feeds/api/users/default/newsubscriptionvideos Without logging in I get this response: User authentication required. Error 401 How can I login to youtube from php?

    Read the article

  • Updating a deallocated UIWebView from a background thread

    - by Dan Ray
    As you can see from the title, I've programmed myself into a corner and I've got several things working against me... In a UIViewController subclass that manages a large and complex view. One part of it is a UIWebView that contains output from a web request that I had to build and execute, and manually assemble HTML from. Since it takes a second or two to run, I dropped it into the background by calling self performSelectorInBackground:. Then from that method I call there, I use self performSelectorOnMainThread: to get back to the surface of the thread stack to update the UIWebView with what I just got. Like this (which I've cut down to show only the relevant issues): -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { //then get mapquest directions NSLog(@"Got called to handle new location!"); [manager stopUpdatingLocation]; [self performSelectorInBackground:@selector(getDirectionsFromHere:) withObject:newLocation]; } - (void)getDirectionsFromHere:(CLLocation *)newLocation { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CLLocationCoordinate2D here = newLocation.coordinate; // assemble a call to the MapQuest directions API in NSString *dirURL // ...cut for brevity NSLog(@"Query is %@", dirURL); NSString *response = [NSString stringWithContentsOfURL:[NSURL URLWithString:dirURL] encoding:NSUTF8StringEncoding error:NULL]; NSMutableString *directionsOutput = [[NSMutableString alloc] init]; // assemble response into an HTML table in NSString *directionsOutput // ...cut for brevity [self performSelectorOnMainThread:@selector(updateDirectionsWithHtml:) withObject:directionsOutput waitUntilDone:NO]; [directionsOutput release]; [pool drain]; [pool release]; } - (void)updateDirectionsWithHtml:(NSString *)directionsOutput { [self.directionsWebView loadHTMLString:directionsOutput baseURL:nil]; } This all works totally great, UNLESS I've backed out of this view controller before CLLocationManager hits its delegate method. If this happens after I've already left this view, I get: 2010-06-07 16:38:08.508 EverWondr[180:760b] bool _WebTryThreadLock(bool), 0x1b6830: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now... Despite what this says, I can repeatably cause this crash when I back out too early. I'm not at all convinced that attempting a UI update from a background thread is really the issue; I think it's that my UIWebView is deallocated. I suspect that the fact I was just IN a background thread makes the runtime suspect something's up about that, but I feel fairly sure that's not it. So how do I tell CLLocationManager not to worry about it, when I'm backing out of that view? I tried [self.locationManager stopUpdatingLocation] inside my viewWillDisappear method, but that didn't do it. (Incidentally, MapQuest's apis are FANTASTIC. Way WAY better than anything Google provides. I can't recommend them highly enough.)

    Read the article

  • How can I get the dimensions of a drawn string without padding?

    - by Dan Herbert
    I'm trying to create an image with some text on it and I want the image's size to match the size of the rendered text. When I use System.Windows.Forms.TextRenderer.MeasureText(...) to measure the text, I get dimensions that include font padding. When the text is rendered, it seems to use the same padding. Is there any way to determine the size of a string of text and then render it without any padding? This is the code I've tried: // Measure the text dimensions var text = "Hello World"; var fontFamily = new Font("Arial", 30, FontStyle.Regular); var textColor = new SolidBrush(Color.Black); Size textSize = TextRenderer.MeasureText(text, fontFamily, Size.Empty, TextFormatFlags.NoPadding); // Render the text with the given dimensions Bitmap bmp = new Bitmap(textSize.Width, textSize.Height); Graphics g = Graphics.FromImage(bmp); g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; g.DrawString(text, fontFamily, textColor, new PointF(0, 0)); bmp.Save("output.png", ImageFormat.Png); This is what currently gets rendered out: This is what I want to render: I also looked into Graphics.MeasureString(...), but that can only be used on an existing Graphics object. I want to know the size before creating the image. Also, calling Graphics.MeasureString(...) returns the same dimensions, so it doesn't help me any.

    Read the article

  • PostSharp when using DataContractSerializer?

    - by Dan Bryant
    I have an Aspect that implements INotifyPropertyChanged on a class. The aspect includes the following: [OnLocationSetValueAdvice, MethodPointcut("SelectProperties")] public void OnPropertySet(LocationInterceptionArgs args) { var currentValue = args.GetCurrentValue(); bool alreadyEqual = (currentValue == args.Value); // Call the setter args.ProceedSetValue(); // Invoke method OnPropertyChanged (ours, the base one, or the overridden one). if (!alreadyEqual) OnPropertyChangedMethod.Invoke(args.Location.Name); } This works fine when I instantiate the class normally, but I run into problems when I deserialize the class using a DataContractSerializer. This bypasses the constructor, which I'm guessing interferes with the way that PostSharp sets itself up. This ends up causing a NullReferenceException in an intercepted property setter, but before it has called the custom OnPropertySet, so I'm guessing it interferes with setting up the LocationInterceptionArgs. Has anyone else encountered this problem? Is there a way I can work around it? I did some more research and discovered I can fix the issue by doing this: [OnDeserializing] private void OnDeserializing(StreamingContext context) { AspectUtilities.InitializeCurrentAspects(); } I thought, okay, that's not too bad, so I tried to do this in my Aspect: private IEnumerable<MethodInfo> SelectDeserializing(Type type) { return type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where( t => t.IsDefined(typeof (OnDeserializingAttribute), false)); } [OnMethodEntryAdvice, MethodPointcut("SelectDeserializing")] public void OnMethodEntry(MethodExecutionArgs args) { AspectUtilities.InitializeCurrentAspects(); } Unfortunately, even though it intercepts the method properly, it doesn't work. I'm thinking the call to InitializeCurrentAspects isn't getting transformed properly, since it's now inside the Aspect rather than directly inside the aspect-enhanced class. Is there a way I can cleanly automate this so that I don't have to worry about calling this on every class that I want to have the Aspect?

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >