Skip to main content

Posts

CGContextSetShadowWithColor not working

This code should be showing a shadow, but it isn't: CGContextRef context = UIGraphicsGetCurrentContext(); //Border CGMutablePathRef outerPath = createRoundedRectForRect(self.bounds, MENU_BUTTON_OUTER_RADIUS); CGContextSetFillColorWithColor(context, [[UIColor colorWithWhite:0 alpha:0.18] CGColor]); CGContextAddPath(context, outerPath); CGContextFillPath(context); //Button UIColor *buttonColor; if (self.type == JMenuButtonTypeBlack) { buttonColor = [UIColor colorWithWhite:0 alpha:1.0]; } else if (self.type == JMenuButtonTypeWhite) { buttonColor = [UIColor colorWithWhite:0.72 alpha:1.0]; } CGRect insideRect = rectForRectWithInset(self.bounds, 3); CGMutablePathRef innerPath = createRoundedRectForRect(insideRect, MENU_BUTTON_INNER_RADIUS); CGPoint gradientTop = CGPointMake(0, insideRect.origin.y); CGPoint gradientBottom = CGPointMake(0, insideRect.origin.y + insideRect.size.height); //Base color CGContextSaveGState(context); CGContextSetFillColorWithColor(context, [buttonColor

insertSubview:belowSubview: in UITableViews

I have a UITableView with UITableViewCell s that are swipable. When a cell is swiped, I want a view to be visible (revealed) underneath that cell. Here's the code that I have: UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; _cellBack = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; _cellBack.backgroundColor = [UIColor whiteColor]; [self.tableView insertSubview:_cellBack belowSubview:cell]; for (int i = 0; i < [self.tableView subviews].count; i++) { UIView *v = [[self.tableView subviews] objectAtIndex:i]; if ([v isEqual:_cellBack]) { NSLog(@"cellBack %d", i); } if ([v isEqual:cell]) { NSLog(@"cell %d", i); } } In the for loop, I check to see if the views' indexes are as I expect, and indeed they are; _cellBack has an index that is one less than cell 's index. When I replace the insertSubview:belowSubview: call wit

dose setHTTPBody need an encoding type

dose setHTTPBody need an encoding type if you are passing it a NSMutable data type though a NSData in the method parameter? Basically I have a method which creates my http body packet along the lines of this - (void) constructRequest { //Create final packet NSMutableData * myConstructedMutableDataPacket = [[NSMutableData alloc] init]; [myConstructedMutableDataPacket appendData:Sig]; [myConstructedMutableDataPacket appendData:Ver]; //etc //call connection method [self [self VehicleSearchRequest:myConstructedMutableDataPacket]; } ]; } then in the connection method is where i declare all my request stuff. Also I am passing the NSMutableData object myConstructedMutableDataPacket over to the NSData parameter of my connection class as listed below. - (IBAction)VehicleSearchRequest:(NSData *)postBodyData { //all my connection crap NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0

Problems in storing data in a H5 file?

double val = 18.5; ByteArrayOutputStream bytestream = new ByteArrayOutputStream(); DataOutputStream datastream = new DataOutputStream(bytestream); datastream.writeDouble(val); datastream.flush(); datastream.close(); bytestream.close(); byte[] bytes = bytestream.toByteArray(); for (int j = 0; j < bytes.length; j++) { write_data[indx] = bytes[j]; indx++; H5.H5Dwrite(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT,write_data); After the data is created and written into the file, when the user tries to open and read the data in HDF view, instead of 18.9, it shows 1.3456789345E45

Preloading a large image

I have an image with the dimensions of 5534 × 3803, and size of 2.4mb. The UIView references notes that: "In iOS 3.0 and later, views are no longer restricted to this maximum size but are still limited by the amount of memory they consume." When the image loads, it lags for half a second, then slides in. The image sits in the UIImageView at 1024x704, but can be scaled up to 4x that size for the purpose of my app. Are you able to preload the image in the AppDelegate? Or is there another way of working around having such a large image? Thanks EDIT: The scaling is done via UIPinchGestureRecognizer, and scales up and done (scale x4 - x1) based on the image's center point. There is no panning of the image when zoomed in.

How to replace the string values stored with in a variable in objective c

I got an xml in output for the webservices.I have the result in the variable and i stored the result in that variable.Now i want to replace the strings in that variable.How to replace the strings in that variable. For ex: //SDZZmaterialGroupList* result = (SDZZmaterialGroupList*)value; in that result variable i stored the result is: </Text></item> <item> <Matkl>00101</Matkl> <Text>Steels</Text> </item> <item> <Matkl>00107</Matkl> <Text>Miscelleanous</Text> </item> <item> <Matkl>002</Matkl> <Text>Electronics</Text> </item> <item> <Matkl>00207</Matkl> <Text>Monitors</Text> </item> <item> <Matkl>003</Matkl> <Text>Bulbs</Text> </item> <item> <Matkl>007</Matkl> <Text>Services</Text> </item> <item> <Matk