UIImageView macht mich gerade fertig

  • UIImageView macht mich gerade fertig

    Hallo,

    ich steh voll auf dem Schlauch.

    Ich hab als Hintergrund View einer TableView eine Image View. Die soll folgendes Bild anzeigen (320x480):

    osxentwicklerforum.de/index.php/Attachment/4745/

    und so siehts aus:

    osxentwicklerforum.de/index.php/Attachment/4746/

    also immer ein Viertel. Ist mit nem Retina Bild das Gleiche, nur weniger pixelig.

    Ich vermute ne versteckte Kammera. Mach mit dem Scheiß jetzt schon seit 2h rum ?(

    Was ist da los?

    Danke
    Manfred
    Seminare, Artikel, Code. ObjectiveCeeds - alles für die Apfelzucht.
  • Einfach als Backgroundimage der TableView. Mit ContentMode und ScaleFactor habei ch schon alles Versucht, bewirkt garnichts.

    setBackgroundImage: soll dann nen Blur über da Bild machen. Hab ich aber mal auskommentiert, so das jetzt nur noch das Bild durchgereicht wird. Hab auch schon versucht das Bild gleich bei der initialisierung der ImageView mitzugeben, also initWithImage - immer das Selbe.


    Quellcode

    1. - (id)init
    2. {
    3. self = [super initWithStyle: UITableViewStylePlain];
    4. if (self) {
    5. [[self tableView] registerClass: [OCFileCell class] forCellReuseIdentifier: @"Cell"];
    6. UIImageView *iv = [[UIImageView alloc] initWithFrame: CGRectZero];
    7. [iv setContentMode: UIViewContentModeScaleAspectFit];
    8. //[iv setContentScaleFactor: 2.0];
    9. [[self tableView] setBackgroundView: iv];
    10. UIImage *img = [UIImage imageNamed: @"back_iphone4.png"];
    11. [self setBackgroundImage: img];
    12. }
    13. return self;
    14. }
    15. - (void) setBackgroundImage:(UIImage *)backgroundImage
    16. {
    17. // CIContext *context = [CIContext contextWithOptions:nil];
    18. //
    19. // CIImage *inputImage = [CIImage imageWithCGImage: [backgroundImage CGImage]];
    20. //
    21. // CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
    22. // [filter setValue:inputImage forKey:kCIInputImageKey];
    23. // [filter setValue:[NSNumber numberWithFloat:25.0f] forKey:@"inputRadius"];
    24. // CIImage *result = [filter valueForKey:kCIOutputImageKey];
    25. //
    26. //
    27. // CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]];
    28. //
    29. // UIImage *resultImg = [UIImage imageWithCGImage:cgImage];
    30. NSLog(@"cgrect %@", NSStringFromCGRect( [[[self tableView] backgroundView] frame]) );
    31. [(UIImageView *)[[self tableView] backgroundView] setImage: backgroundImage];
    32. }
    Alles anzeigen
    Seminare, Artikel, Code. ObjectiveCeeds - alles für die Apfelzucht.
  • Eigentlich ja.

    Habs probiert, frames stimmen, aber nichts passiert. In eine Containerview hab ich die ImageView auch schon gepackt.

    - (id)init
    {
    self = [super initWithStyle: UITableViewStylePlain];
    if (self) {

    [[self tableView] registerClass: [OCGameCell class] forCellReuseIdentifier: @"Cell"];

    NSLog(@"cgrect %@", NSStringFromCGRect( [[self tableView] frame]) );


    UIImageView *iv = [[UIImageView alloc] initWithFrame: [[self tableView] frame]];
    [iv setContentMode: UIViewContentModeScaleAspectFit];
    [iv setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
    //[iv setContentScaleFactor: 2.0];

    UIView *con = [[UIView alloc] initWithFrame: CGRectZero];
    //[con addSubview: iv];

    [[self tableView] setBackgroundView: iv];
    // [[self tableView] setBackgroundColor: [UIColor clearColor]];

    UIImage *img = [UIImage imageNamed: @"back_iphone4.png"];

    //[self setBackgroundImage: img];

    [iv setImage: img];
    }
    return self;
    }
    Seminare, Artikel, Code. ObjectiveCeeds - alles für die Apfelzucht.
  • Manfred Kreß schrieb:

    Der Scale ist 1.0.

    Ich pack jetzt ne View hinter die TableView und mach das mit dem Hintergrund selbst. Kann ja jetzt nicht ne Woche an dem Sch... sitzen.


    Ja genau das habe ich dann auch gemacht damals. Ich habe es auch nicht hinbekommen in die TableView einen gewünschten Hintergrund zu integrieren. Deshalb auch meine erste Frage.

    Gruß

    Claus
    2 Stunden Try & Error erspart 10 Minuten Handbuchlesen.

    Pre-Kaffee-Posts sind mit Vorsicht zu geniessen :)
  • Meine Nerven sind zerrüttet. Auch hier wird alles gestreckt.

    Quellcode

    1. #import "OCTableViewController.h"
    2. @interface OCTableViewController ()
    3. @property (readonly) UIView *containerView;
    4. @property (readonly) UIImageView *backgroundView;
    5. @end
    6. @implementation OCTableViewController
    7. @dynamic backgroundImage;
    8. - (id)initWithStyle: (UITableViewStyle)style
    9. {
    10. self = [super init];
    11. if (self) {
    12. _tableView = [[UITableView alloc] initWithFrame: CGRectZero style: style];
    13. [_tableView setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    14. [_tableView setDataSource: self];
    15. [_tableView setDelegate: self];
    16. [_tableView setBackgroundView: nil];
    17. [_tableView setBackgroundColor: nil];
    18. _backgroundView = [[UIImageView alloc] initWithFrame: CGRectZero];
    19. [_backgroundView setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    20. _containerView = [[UIView alloc] initWithFrame: CGRectZero];
    21. [_backgroundView setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    22. [_containerView addSubview: _backgroundView];
    23. [_containerView addSubview: _tableView];
    24. [self setView: _containerView];
    25. }
    26. return self;
    27. }
    28. - (void)setBackgroundImage:(UIImage *)backgroundImage
    29. {
    30. [_backgroundView setImage: backgroundImage];
    31. }
    32. - (UIImage *) backgroundImage
    33. {
    34. return [_backgroundView image];
    35. }
    36. #pragma mark - Table view data source
    37. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    38. {
    39. return 0;
    40. }
    41. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    42. {
    43. return 0;
    44. }
    45. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    46. {
    47. static NSString *CellIdentifier = @"Cell";
    48. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    49. return cell;
    50. }
    51. @end
    Alles anzeigen
    Seminare, Artikel, Code. ObjectiveCeeds - alles für die Apfelzucht.